
user/_testsh:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <rand>:

// return a random integer.
// from Wikipedia, linear congruential generator, glibc's constants.
unsigned int
rand()
{
       0:	1141                	addi	sp,sp,-16
       2:	e422                	sd	s0,8(sp)
       4:	0800                	addi	s0,sp,16
  unsigned int a = 1103515245;
  unsigned int c = 12345;
  unsigned int m = (1 << 31);
  seed = (a * seed + c) % m;
       6:	00002717          	auipc	a4,0x2
       a:	8aa70713          	addi	a4,a4,-1878 # 18b0 <seed>
       e:	4308                	lw	a0,0(a4)
      10:	41c657b7          	lui	a5,0x41c65
      14:	e6d7879b          	addiw	a5,a5,-403
      18:	02f5053b          	mulw	a0,a0,a5
      1c:	678d                	lui	a5,0x3
      1e:	0397879b          	addiw	a5,a5,57
      22:	9d3d                	addw	a0,a0,a5
      24:	800007b7          	lui	a5,0x80000
      28:	fff7c793          	not	a5,a5
      2c:	8d7d                	and	a0,a0,a5
      2e:	2501                	sext.w	a0,a0
      30:	c308                	sw	a0,0(a4)
  return seed;
}
      32:	6422                	ld	s0,8(sp)
      34:	0141                	addi	sp,sp,16
      36:	8082                	ret

0000000000000038 <randstring>:

// generate a random string of the indicated length.
char *
randstring(char *buf, int n)
{
      38:	7139                	addi	sp,sp,-64
      3a:	fc06                	sd	ra,56(sp)
      3c:	f822                	sd	s0,48(sp)
      3e:	f426                	sd	s1,40(sp)
      40:	f04a                	sd	s2,32(sp)
      42:	ec4e                	sd	s3,24(sp)
      44:	e852                	sd	s4,16(sp)
      46:	e456                	sd	s5,8(sp)
      48:	e05a                	sd	s6,0(sp)
      4a:	0080                	addi	s0,sp,64
      4c:	8aaa                	mv	s5,a0
      4e:	8a2e                	mv	s4,a1
  for(int i = 0; i < n-1; i++)
      50:	4785                	li	a5,1
      52:	02b7df63          	ble	a1,a5,90 <randstring+0x58>
      56:	84aa                	mv	s1,a0
      58:	00150913          	addi	s2,a0,1
      5c:	ffe5879b          	addiw	a5,a1,-2
      60:	1782                	slli	a5,a5,0x20
      62:	9381                	srli	a5,a5,0x20
      64:	993e                	add	s2,s2,a5
    buf[i] = "abcdefghijklmnopqrstuvwxyz"[rand() % 26];
      66:	00001b17          	auipc	s6,0x1
      6a:	412b0b13          	addi	s6,s6,1042 # 1478 <malloc+0xe6>
      6e:	49e9                	li	s3,26
      70:	00000097          	auipc	ra,0x0
      74:	f90080e7          	jalr	-112(ra) # 0 <rand>
      78:	0335753b          	remuw	a0,a0,s3
      7c:	1502                	slli	a0,a0,0x20
      7e:	9101                	srli	a0,a0,0x20
      80:	955a                	add	a0,a0,s6
      82:	00054783          	lbu	a5,0(a0)
      86:	00f48023          	sb	a5,0(s1)
  for(int i = 0; i < n-1; i++)
      8a:	0485                	addi	s1,s1,1
      8c:	ff2492e3          	bne	s1,s2,70 <randstring+0x38>
  buf[n-1] = '\0';
      90:	9a56                	add	s4,s4,s5
      92:	fe0a0fa3          	sb	zero,-1(s4)
  return buf;
}
      96:	8556                	mv	a0,s5
      98:	70e2                	ld	ra,56(sp)
      9a:	7442                	ld	s0,48(sp)
      9c:	74a2                	ld	s1,40(sp)
      9e:	7902                	ld	s2,32(sp)
      a0:	69e2                	ld	s3,24(sp)
      a2:	6a42                	ld	s4,16(sp)
      a4:	6aa2                	ld	s5,8(sp)
      a6:	6b02                	ld	s6,0(sp)
      a8:	6121                	addi	sp,sp,64
      aa:	8082                	ret

00000000000000ac <writefile>:

// create a file with the indicated content.
void
writefile(char *name, char *data)
{
      ac:	7179                	addi	sp,sp,-48
      ae:	f406                	sd	ra,40(sp)
      b0:	f022                	sd	s0,32(sp)
      b2:	ec26                	sd	s1,24(sp)
      b4:	e84a                	sd	s2,16(sp)
      b6:	e44e                	sd	s3,8(sp)
      b8:	1800                	addi	s0,sp,48
      ba:	89aa                	mv	s3,a0
      bc:	892e                	mv	s2,a1
  unlink(name); // since no truncation
      be:	00001097          	auipc	ra,0x1
      c2:	ee4080e7          	jalr	-284(ra) # fa2 <unlink>
  int fd = open(name, O_CREATE|O_WRONLY);
      c6:	20100593          	li	a1,513
      ca:	854e                	mv	a0,s3
      cc:	00001097          	auipc	ra,0x1
      d0:	ec6080e7          	jalr	-314(ra) # f92 <open>
  if(fd < 0){
      d4:	04054663          	bltz	a0,120 <writefile+0x74>
      d8:	84aa                	mv	s1,a0
    fprintf(2, "testsh: could not write %s\n", name);
    exit(-1);
  }
  if(write(fd, data, strlen(data)) != strlen(data)){
      da:	854a                	mv	a0,s2
      dc:	00001097          	auipc	ra,0x1
      e0:	c36080e7          	jalr	-970(ra) # d12 <strlen>
      e4:	0005061b          	sext.w	a2,a0
      e8:	85ca                	mv	a1,s2
      ea:	8526                	mv	a0,s1
      ec:	00001097          	auipc	ra,0x1
      f0:	e86080e7          	jalr	-378(ra) # f72 <write>
      f4:	89aa                	mv	s3,a0
      f6:	854a                	mv	a0,s2
      f8:	00001097          	auipc	ra,0x1
      fc:	c1a080e7          	jalr	-998(ra) # d12 <strlen>
     100:	2501                	sext.w	a0,a0
     102:	2981                	sext.w	s3,s3
     104:	02a99d63          	bne	s3,a0,13e <writefile+0x92>
    fprintf(2, "testsh: write failed\n");
    exit(-1);
  }
  close(fd);
     108:	8526                	mv	a0,s1
     10a:	00001097          	auipc	ra,0x1
     10e:	e70080e7          	jalr	-400(ra) # f7a <close>
}
     112:	70a2                	ld	ra,40(sp)
     114:	7402                	ld	s0,32(sp)
     116:	64e2                	ld	s1,24(sp)
     118:	6942                	ld	s2,16(sp)
     11a:	69a2                	ld	s3,8(sp)
     11c:	6145                	addi	sp,sp,48
     11e:	8082                	ret
    fprintf(2, "testsh: could not write %s\n", name);
     120:	864e                	mv	a2,s3
     122:	00001597          	auipc	a1,0x1
     126:	37658593          	addi	a1,a1,886 # 1498 <malloc+0x106>
     12a:	4509                	li	a0,2
     12c:	00001097          	auipc	ra,0x1
     130:	178080e7          	jalr	376(ra) # 12a4 <fprintf>
    exit(-1);
     134:	557d                	li	a0,-1
     136:	00001097          	auipc	ra,0x1
     13a:	e1c080e7          	jalr	-484(ra) # f52 <exit>
    fprintf(2, "testsh: write failed\n");
     13e:	00001597          	auipc	a1,0x1
     142:	37a58593          	addi	a1,a1,890 # 14b8 <malloc+0x126>
     146:	4509                	li	a0,2
     148:	00001097          	auipc	ra,0x1
     14c:	15c080e7          	jalr	348(ra) # 12a4 <fprintf>
    exit(-1);
     150:	557d                	li	a0,-1
     152:	00001097          	auipc	ra,0x1
     156:	e00080e7          	jalr	-512(ra) # f52 <exit>

000000000000015a <readfile>:

// return the content of a file.
void
readfile(char *name, char *data, int max)
{
     15a:	7179                	addi	sp,sp,-48
     15c:	f406                	sd	ra,40(sp)
     15e:	f022                	sd	s0,32(sp)
     160:	ec26                	sd	s1,24(sp)
     162:	e84a                	sd	s2,16(sp)
     164:	e44e                	sd	s3,8(sp)
     166:	e052                	sd	s4,0(sp)
     168:	1800                	addi	s0,sp,48
     16a:	8a2a                	mv	s4,a0
     16c:	84ae                	mv	s1,a1
     16e:	89b2                	mv	s3,a2
  data[0] = '\0';
     170:	00058023          	sb	zero,0(a1)
  int fd = open(name, 0);
     174:	4581                	li	a1,0
     176:	00001097          	auipc	ra,0x1
     17a:	e1c080e7          	jalr	-484(ra) # f92 <open>
  if(fd < 0){
     17e:	02054d63          	bltz	a0,1b8 <readfile+0x5e>
     182:	892a                	mv	s2,a0
    fprintf(2, "testsh: open %s failed\n", name);
    return;
  }
  int n = read(fd, data, max-1);
     184:	fff9861b          	addiw	a2,s3,-1
     188:	85a6                	mv	a1,s1
     18a:	00001097          	auipc	ra,0x1
     18e:	de0080e7          	jalr	-544(ra) # f6a <read>
     192:	89aa                	mv	s3,a0
  close(fd);
     194:	854a                	mv	a0,s2
     196:	00001097          	auipc	ra,0x1
     19a:	de4080e7          	jalr	-540(ra) # f7a <close>
  if(n < 0){
     19e:	0209c863          	bltz	s3,1ce <readfile+0x74>
    fprintf(2, "testsh: read %s failed\n", name);
    return;
  }
  data[n] = '\0';
     1a2:	94ce                	add	s1,s1,s3
     1a4:	00048023          	sb	zero,0(s1)
}
     1a8:	70a2                	ld	ra,40(sp)
     1aa:	7402                	ld	s0,32(sp)
     1ac:	64e2                	ld	s1,24(sp)
     1ae:	6942                	ld	s2,16(sp)
     1b0:	69a2                	ld	s3,8(sp)
     1b2:	6a02                	ld	s4,0(sp)
     1b4:	6145                	addi	sp,sp,48
     1b6:	8082                	ret
    fprintf(2, "testsh: open %s failed\n", name);
     1b8:	8652                	mv	a2,s4
     1ba:	00001597          	auipc	a1,0x1
     1be:	31658593          	addi	a1,a1,790 # 14d0 <malloc+0x13e>
     1c2:	4509                	li	a0,2
     1c4:	00001097          	auipc	ra,0x1
     1c8:	0e0080e7          	jalr	224(ra) # 12a4 <fprintf>
    return;
     1cc:	bff1                	j	1a8 <readfile+0x4e>
    fprintf(2, "testsh: read %s failed\n", name);
     1ce:	8652                	mv	a2,s4
     1d0:	00001597          	auipc	a1,0x1
     1d4:	31858593          	addi	a1,a1,792 # 14e8 <malloc+0x156>
     1d8:	4509                	li	a0,2
     1da:	00001097          	auipc	ra,0x1
     1de:	0ca080e7          	jalr	202(ra) # 12a4 <fprintf>
    return;
     1e2:	b7d9                	j	1a8 <readfile+0x4e>

00000000000001e4 <strstr>:

// look for the small string in the big string;
// return the address in the big string, or 0.
char *
strstr(char *big, char *small)
{
     1e4:	1141                	addi	sp,sp,-16
     1e6:	e422                	sd	s0,8(sp)
     1e8:	0800                	addi	s0,sp,16
  if(small[0] == '\0')
     1ea:	0005c803          	lbu	a6,0(a1)
     1ee:	02080e63          	beqz	a6,22a <strstr+0x46>
    return big;
  for(int i = 0; big[i]; i++){
     1f2:	00054783          	lbu	a5,0(a0)
     1f6:	e799                	bnez	a5,204 <strstr+0x20>
    }
    if(small[j] == '\0'){
      return big + i;
    }
  }
  return 0;
     1f8:	4501                	li	a0,0
     1fa:	a805                	j	22a <strstr+0x46>
  for(int i = 0; big[i]; i++){
     1fc:	0505                	addi	a0,a0,1
     1fe:	00054783          	lbu	a5,0(a0)
     202:	c39d                	beqz	a5,228 <strstr+0x44>
      if(big[i+j] != small[j]){
     204:	00054783          	lbu	a5,0(a0)
     208:	ff079ae3          	bne	a5,a6,1fc <strstr+0x18>
     20c:	00158793          	addi	a5,a1,1
     210:	00150713          	addi	a4,a0,1
    for(j = 0; small[j]; j++){
     214:	0007c683          	lbu	a3,0(a5) # ffffffff80000000 <__global_pointer$+0xffffffff7fffdf50>
     218:	ca89                	beqz	a3,22a <strstr+0x46>
      if(big[i+j] != small[j]){
     21a:	00074603          	lbu	a2,0(a4)
     21e:	0785                	addi	a5,a5,1
     220:	0705                	addi	a4,a4,1
     222:	fed609e3          	beq	a2,a3,214 <strstr+0x30>
     226:	bfd9                	j	1fc <strstr+0x18>
  return 0;
     228:	4501                	li	a0,0
}
     22a:	6422                	ld	s0,8(sp)
     22c:	0141                	addi	sp,sp,16
     22e:	8082                	ret

0000000000000230 <one>:
// its input, collect the output, check that the
// output includes the expect argument.
// if tight = 1, don't allow much extraneous output.
int
one(char *cmd, char *expect, int tight)
{
     230:	710d                	addi	sp,sp,-352
     232:	ee86                	sd	ra,344(sp)
     234:	eaa2                	sd	s0,336(sp)
     236:	e6a6                	sd	s1,328(sp)
     238:	e2ca                	sd	s2,320(sp)
     23a:	fe4e                	sd	s3,312(sp)
     23c:	1280                	addi	s0,sp,352
     23e:	84aa                	mv	s1,a0
     240:	892e                	mv	s2,a1
     242:	89b2                	mv	s3,a2
  char infile[12], outfile[12];

  randstring(infile, sizeof(infile));
     244:	45b1                	li	a1,12
     246:	fc040513          	addi	a0,s0,-64
     24a:	00000097          	auipc	ra,0x0
     24e:	dee080e7          	jalr	-530(ra) # 38 <randstring>
  randstring(outfile, sizeof(outfile));
     252:	45b1                	li	a1,12
     254:	fb040513          	addi	a0,s0,-80
     258:	00000097          	auipc	ra,0x0
     25c:	de0080e7          	jalr	-544(ra) # 38 <randstring>

  writefile(infile, cmd);
     260:	85a6                	mv	a1,s1
     262:	fc040513          	addi	a0,s0,-64
     266:	00000097          	auipc	ra,0x0
     26a:	e46080e7          	jalr	-442(ra) # ac <writefile>
  unlink(outfile);
     26e:	fb040513          	addi	a0,s0,-80
     272:	00001097          	auipc	ra,0x1
     276:	d30080e7          	jalr	-720(ra) # fa2 <unlink>

  int pid = fork();
     27a:	00001097          	auipc	ra,0x1
     27e:	cd0080e7          	jalr	-816(ra) # f4a <fork>
  if(pid < 0){
     282:	04054f63          	bltz	a0,2e0 <one+0xb0>
     286:	84aa                	mv	s1,a0
    fprintf(2, "testsh: fork() failed\n");
    exit(-1);
  }

  if(pid == 0){
     288:	e571                	bnez	a0,354 <one+0x124>
    close(0);
     28a:	4501                	li	a0,0
     28c:	00001097          	auipc	ra,0x1
     290:	cee080e7          	jalr	-786(ra) # f7a <close>
    if(open(infile, 0) != 0){
     294:	4581                	li	a1,0
     296:	fc040513          	addi	a0,s0,-64
     29a:	00001097          	auipc	ra,0x1
     29e:	cf8080e7          	jalr	-776(ra) # f92 <open>
     2a2:	ed29                	bnez	a0,2fc <one+0xcc>
      fprintf(2, "testsh: child open != 0\n");
      exit(-1);
    }
    close(1);
     2a4:	4505                	li	a0,1
     2a6:	00001097          	auipc	ra,0x1
     2aa:	cd4080e7          	jalr	-812(ra) # f7a <close>
    if(open(outfile, O_CREATE|O_WRONLY) != 1){
     2ae:	20100593          	li	a1,513
     2b2:	fb040513          	addi	a0,s0,-80
     2b6:	00001097          	auipc	ra,0x1
     2ba:	cdc080e7          	jalr	-804(ra) # f92 <open>
     2be:	4785                	li	a5,1
     2c0:	04f50c63          	beq	a0,a5,318 <one+0xe8>
      fprintf(2, "testsh: child open != 1\n");
     2c4:	00001597          	auipc	a1,0x1
     2c8:	27458593          	addi	a1,a1,628 # 1538 <malloc+0x1a6>
     2cc:	4509                	li	a0,2
     2ce:	00001097          	auipc	ra,0x1
     2d2:	fd6080e7          	jalr	-42(ra) # 12a4 <fprintf>
      exit(-1);
     2d6:	557d                	li	a0,-1
     2d8:	00001097          	auipc	ra,0x1
     2dc:	c7a080e7          	jalr	-902(ra) # f52 <exit>
    fprintf(2, "testsh: fork() failed\n");
     2e0:	00001597          	auipc	a1,0x1
     2e4:	22058593          	addi	a1,a1,544 # 1500 <malloc+0x16e>
     2e8:	4509                	li	a0,2
     2ea:	00001097          	auipc	ra,0x1
     2ee:	fba080e7          	jalr	-70(ra) # 12a4 <fprintf>
    exit(-1);
     2f2:	557d                	li	a0,-1
     2f4:	00001097          	auipc	ra,0x1
     2f8:	c5e080e7          	jalr	-930(ra) # f52 <exit>
      fprintf(2, "testsh: child open != 0\n");
     2fc:	00001597          	auipc	a1,0x1
     300:	21c58593          	addi	a1,a1,540 # 1518 <malloc+0x186>
     304:	4509                	li	a0,2
     306:	00001097          	auipc	ra,0x1
     30a:	f9e080e7          	jalr	-98(ra) # 12a4 <fprintf>
      exit(-1);
     30e:	557d                	li	a0,-1
     310:	00001097          	auipc	ra,0x1
     314:	c42080e7          	jalr	-958(ra) # f52 <exit>
    }
    char *argv[2];
    argv[0] = shname;
     318:	00001497          	auipc	s1,0x1
     31c:	5a048493          	addi	s1,s1,1440 # 18b8 <shname>
     320:	6088                	ld	a0,0(s1)
     322:	eaa43023          	sd	a0,-352(s0)
    argv[1] = 0;
     326:	ea043423          	sd	zero,-344(s0)
    exec(shname, argv);
     32a:	ea040593          	addi	a1,s0,-352
     32e:	00001097          	auipc	ra,0x1
     332:	c5c080e7          	jalr	-932(ra) # f8a <exec>
    fprintf(2, "testsh: exec %s failed\n", shname);
     336:	6090                	ld	a2,0(s1)
     338:	00001597          	auipc	a1,0x1
     33c:	22058593          	addi	a1,a1,544 # 1558 <malloc+0x1c6>
     340:	4509                	li	a0,2
     342:	00001097          	auipc	ra,0x1
     346:	f62080e7          	jalr	-158(ra) # 12a4 <fprintf>
    exit(-1);
     34a:	557d                	li	a0,-1
     34c:	00001097          	auipc	ra,0x1
     350:	c06080e7          	jalr	-1018(ra) # f52 <exit>
  }

  if(wait(0) != pid){
     354:	4501                	li	a0,0
     356:	00001097          	auipc	ra,0x1
     35a:	c04080e7          	jalr	-1020(ra) # f5a <wait>
     35e:	04951c63          	bne	a0,s1,3b6 <one+0x186>
    fprintf(2, "testsh: unexpected wait() return\n");
    exit(-1);
  }
  unlink(infile);
     362:	fc040513          	addi	a0,s0,-64
     366:	00001097          	auipc	ra,0x1
     36a:	c3c080e7          	jalr	-964(ra) # fa2 <unlink>

  char out[256];
  readfile(outfile, out, sizeof(out));
     36e:	10000613          	li	a2,256
     372:	eb040593          	addi	a1,s0,-336
     376:	fb040513          	addi	a0,s0,-80
     37a:	00000097          	auipc	ra,0x0
     37e:	de0080e7          	jalr	-544(ra) # 15a <readfile>
  unlink(outfile);
     382:	fb040513          	addi	a0,s0,-80
     386:	00001097          	auipc	ra,0x1
     38a:	c1c080e7          	jalr	-996(ra) # fa2 <unlink>

  if(strstr(out, expect) != 0){
     38e:	85ca                	mv	a1,s2
     390:	eb040513          	addi	a0,s0,-336
     394:	00000097          	auipc	ra,0x0
     398:	e50080e7          	jalr	-432(ra) # 1e4 <strstr>
      fprintf(2, "testsh: saw expected output, but too much else as well\n");
      return 0; // fail
    }
    return 1; // pass
  }
  return 0; // fail
     39c:	4781                	li	a5,0
  if(strstr(out, expect) != 0){
     39e:	c501                	beqz	a0,3a6 <one+0x176>
    return 1; // pass
     3a0:	4785                	li	a5,1
    if(tight && strlen(out) > strlen(expect) + 10){
     3a2:	02099863          	bnez	s3,3d2 <one+0x1a2>
}
     3a6:	853e                	mv	a0,a5
     3a8:	60f6                	ld	ra,344(sp)
     3aa:	6456                	ld	s0,336(sp)
     3ac:	64b6                	ld	s1,328(sp)
     3ae:	6916                	ld	s2,320(sp)
     3b0:	79f2                	ld	s3,312(sp)
     3b2:	6135                	addi	sp,sp,352
     3b4:	8082                	ret
    fprintf(2, "testsh: unexpected wait() return\n");
     3b6:	00001597          	auipc	a1,0x1
     3ba:	1ba58593          	addi	a1,a1,442 # 1570 <malloc+0x1de>
     3be:	4509                	li	a0,2
     3c0:	00001097          	auipc	ra,0x1
     3c4:	ee4080e7          	jalr	-284(ra) # 12a4 <fprintf>
    exit(-1);
     3c8:	557d                	li	a0,-1
     3ca:	00001097          	auipc	ra,0x1
     3ce:	b88080e7          	jalr	-1144(ra) # f52 <exit>
    if(tight && strlen(out) > strlen(expect) + 10){
     3d2:	eb040513          	addi	a0,s0,-336
     3d6:	00001097          	auipc	ra,0x1
     3da:	93c080e7          	jalr	-1732(ra) # d12 <strlen>
     3de:	0005049b          	sext.w	s1,a0
     3e2:	854a                	mv	a0,s2
     3e4:	00001097          	auipc	ra,0x1
     3e8:	92e080e7          	jalr	-1746(ra) # d12 <strlen>
     3ec:	2529                	addiw	a0,a0,10
    return 1; // pass
     3ee:	4785                	li	a5,1
    if(tight && strlen(out) > strlen(expect) + 10){
     3f0:	fa957be3          	bleu	s1,a0,3a6 <one+0x176>
      fprintf(2, "testsh: saw expected output, but too much else as well\n");
     3f4:	00001597          	auipc	a1,0x1
     3f8:	1a458593          	addi	a1,a1,420 # 1598 <malloc+0x206>
     3fc:	4509                	li	a0,2
     3fe:	00001097          	auipc	ra,0x1
     402:	ea6080e7          	jalr	-346(ra) # 12a4 <fprintf>
      return 0; // fail
     406:	4781                	li	a5,0
     408:	bf79                	j	3a6 <one+0x176>

000000000000040a <t1>:

// test a command with arguments.
void
t1(int *ok)
{
     40a:	1101                	addi	sp,sp,-32
     40c:	ec06                	sd	ra,24(sp)
     40e:	e822                	sd	s0,16(sp)
     410:	e426                	sd	s1,8(sp)
     412:	1000                	addi	s0,sp,32
     414:	84aa                	mv	s1,a0
  printf("simple echo: ");
     416:	00001517          	auipc	a0,0x1
     41a:	1ba50513          	addi	a0,a0,442 # 15d0 <malloc+0x23e>
     41e:	00001097          	auipc	ra,0x1
     422:	eb4080e7          	jalr	-332(ra) # 12d2 <printf>
  if(one("echo hello goodbye\n", "hello goodbye", 1) == 0){
     426:	4605                	li	a2,1
     428:	00001597          	auipc	a1,0x1
     42c:	1b858593          	addi	a1,a1,440 # 15e0 <malloc+0x24e>
     430:	00001517          	auipc	a0,0x1
     434:	1c050513          	addi	a0,a0,448 # 15f0 <malloc+0x25e>
     438:	00000097          	auipc	ra,0x0
     43c:	df8080e7          	jalr	-520(ra) # 230 <one>
     440:	e105                	bnez	a0,460 <t1+0x56>
    printf("FAIL\n");
     442:	00001517          	auipc	a0,0x1
     446:	1c650513          	addi	a0,a0,454 # 1608 <malloc+0x276>
     44a:	00001097          	auipc	ra,0x1
     44e:	e88080e7          	jalr	-376(ra) # 12d2 <printf>
    *ok = 0;
     452:	0004a023          	sw	zero,0(s1)
  } else {
    printf("PASS\n");
  }
}
     456:	60e2                	ld	ra,24(sp)
     458:	6442                	ld	s0,16(sp)
     45a:	64a2                	ld	s1,8(sp)
     45c:	6105                	addi	sp,sp,32
     45e:	8082                	ret
    printf("PASS\n");
     460:	00001517          	auipc	a0,0x1
     464:	1b050513          	addi	a0,a0,432 # 1610 <malloc+0x27e>
     468:	00001097          	auipc	ra,0x1
     46c:	e6a080e7          	jalr	-406(ra) # 12d2 <printf>
}
     470:	b7dd                	j	456 <t1+0x4c>

0000000000000472 <t2>:

// test a command with arguments.
void
t2(int *ok)
{
     472:	1101                	addi	sp,sp,-32
     474:	ec06                	sd	ra,24(sp)
     476:	e822                	sd	s0,16(sp)
     478:	e426                	sd	s1,8(sp)
     47a:	1000                	addi	s0,sp,32
     47c:	84aa                	mv	s1,a0
  printf("simple grep: ");
     47e:	00001517          	auipc	a0,0x1
     482:	19a50513          	addi	a0,a0,410 # 1618 <malloc+0x286>
     486:	00001097          	auipc	ra,0x1
     48a:	e4c080e7          	jalr	-436(ra) # 12d2 <printf>
  if(one("grep constitute README\n", "The code in the files that constitute xv6 is", 1) == 0){
     48e:	4605                	li	a2,1
     490:	00001597          	auipc	a1,0x1
     494:	19858593          	addi	a1,a1,408 # 1628 <malloc+0x296>
     498:	00001517          	auipc	a0,0x1
     49c:	1c050513          	addi	a0,a0,448 # 1658 <malloc+0x2c6>
     4a0:	00000097          	auipc	ra,0x0
     4a4:	d90080e7          	jalr	-624(ra) # 230 <one>
     4a8:	e105                	bnez	a0,4c8 <t2+0x56>
    printf("FAIL\n");
     4aa:	00001517          	auipc	a0,0x1
     4ae:	15e50513          	addi	a0,a0,350 # 1608 <malloc+0x276>
     4b2:	00001097          	auipc	ra,0x1
     4b6:	e20080e7          	jalr	-480(ra) # 12d2 <printf>
    *ok = 0;
     4ba:	0004a023          	sw	zero,0(s1)
  } else {
    printf("PASS\n");
  }
}
     4be:	60e2                	ld	ra,24(sp)
     4c0:	6442                	ld	s0,16(sp)
     4c2:	64a2                	ld	s1,8(sp)
     4c4:	6105                	addi	sp,sp,32
     4c6:	8082                	ret
    printf("PASS\n");
     4c8:	00001517          	auipc	a0,0x1
     4cc:	14850513          	addi	a0,a0,328 # 1610 <malloc+0x27e>
     4d0:	00001097          	auipc	ra,0x1
     4d4:	e02080e7          	jalr	-510(ra) # 12d2 <printf>
}
     4d8:	b7dd                	j	4be <t2+0x4c>

00000000000004da <t3>:

// test a command, then a newline, then another command.
void
t3(int *ok)
{
     4da:	1101                	addi	sp,sp,-32
     4dc:	ec06                	sd	ra,24(sp)
     4de:	e822                	sd	s0,16(sp)
     4e0:	e426                	sd	s1,8(sp)
     4e2:	1000                	addi	s0,sp,32
     4e4:	84aa                	mv	s1,a0
  printf("two commands: ");
     4e6:	00001517          	auipc	a0,0x1
     4ea:	18a50513          	addi	a0,a0,394 # 1670 <malloc+0x2de>
     4ee:	00001097          	auipc	ra,0x1
     4f2:	de4080e7          	jalr	-540(ra) # 12d2 <printf>
  if(one("echo x\necho goodbye\n", "goodbye", 1) == 0){
     4f6:	4605                	li	a2,1
     4f8:	00001597          	auipc	a1,0x1
     4fc:	18858593          	addi	a1,a1,392 # 1680 <malloc+0x2ee>
     500:	00001517          	auipc	a0,0x1
     504:	18850513          	addi	a0,a0,392 # 1688 <malloc+0x2f6>
     508:	00000097          	auipc	ra,0x0
     50c:	d28080e7          	jalr	-728(ra) # 230 <one>
     510:	e105                	bnez	a0,530 <t3+0x56>
    printf("FAIL\n");
     512:	00001517          	auipc	a0,0x1
     516:	0f650513          	addi	a0,a0,246 # 1608 <malloc+0x276>
     51a:	00001097          	auipc	ra,0x1
     51e:	db8080e7          	jalr	-584(ra) # 12d2 <printf>
    *ok = 0;
     522:	0004a023          	sw	zero,0(s1)
  } else {
    printf("PASS\n");
  }
}
     526:	60e2                	ld	ra,24(sp)
     528:	6442                	ld	s0,16(sp)
     52a:	64a2                	ld	s1,8(sp)
     52c:	6105                	addi	sp,sp,32
     52e:	8082                	ret
    printf("PASS\n");
     530:	00001517          	auipc	a0,0x1
     534:	0e050513          	addi	a0,a0,224 # 1610 <malloc+0x27e>
     538:	00001097          	auipc	ra,0x1
     53c:	d9a080e7          	jalr	-614(ra) # 12d2 <printf>
}
     540:	b7dd                	j	526 <t3+0x4c>

0000000000000542 <t4>:

// test output redirection: echo xxx > file
void
t4(int *ok)
{
     542:	7131                	addi	sp,sp,-192
     544:	fd06                	sd	ra,184(sp)
     546:	f922                	sd	s0,176(sp)
     548:	f526                	sd	s1,168(sp)
     54a:	0180                	addi	s0,sp,192
     54c:	84aa                	mv	s1,a0
  printf("output redirection: ");
     54e:	00001517          	auipc	a0,0x1
     552:	15250513          	addi	a0,a0,338 # 16a0 <malloc+0x30e>
     556:	00001097          	auipc	ra,0x1
     55a:	d7c080e7          	jalr	-644(ra) # 12d2 <printf>

  char file[16];
  randstring(file, 12);
     55e:	45b1                	li	a1,12
     560:	fd040513          	addi	a0,s0,-48
     564:	00000097          	auipc	ra,0x0
     568:	ad4080e7          	jalr	-1324(ra) # 38 <randstring>

  char data[16];
  randstring(data, 12);
     56c:	45b1                	li	a1,12
     56e:	fc040513          	addi	a0,s0,-64
     572:	00000097          	auipc	ra,0x0
     576:	ac6080e7          	jalr	-1338(ra) # 38 <randstring>

  char cmd[64];
  strcpy(cmd, "echo ");
     57a:	00001597          	auipc	a1,0x1
     57e:	13e58593          	addi	a1,a1,318 # 16b8 <malloc+0x326>
     582:	f8040513          	addi	a0,s0,-128
     586:	00000097          	auipc	ra,0x0
     58a:	73c080e7          	jalr	1852(ra) # cc2 <strcpy>
  strcpy(cmd+strlen(cmd), data);
     58e:	f8040513          	addi	a0,s0,-128
     592:	00000097          	auipc	ra,0x0
     596:	780080e7          	jalr	1920(ra) # d12 <strlen>
     59a:	1502                	slli	a0,a0,0x20
     59c:	9101                	srli	a0,a0,0x20
     59e:	fc040593          	addi	a1,s0,-64
     5a2:	f8040793          	addi	a5,s0,-128
     5a6:	953e                	add	a0,a0,a5
     5a8:	00000097          	auipc	ra,0x0
     5ac:	71a080e7          	jalr	1818(ra) # cc2 <strcpy>
  strcpy(cmd+strlen(cmd), " > ");
     5b0:	f8040513          	addi	a0,s0,-128
     5b4:	00000097          	auipc	ra,0x0
     5b8:	75e080e7          	jalr	1886(ra) # d12 <strlen>
     5bc:	1502                	slli	a0,a0,0x20
     5be:	9101                	srli	a0,a0,0x20
     5c0:	00001597          	auipc	a1,0x1
     5c4:	10058593          	addi	a1,a1,256 # 16c0 <malloc+0x32e>
     5c8:	f8040793          	addi	a5,s0,-128
     5cc:	953e                	add	a0,a0,a5
     5ce:	00000097          	auipc	ra,0x0
     5d2:	6f4080e7          	jalr	1780(ra) # cc2 <strcpy>
  strcpy(cmd+strlen(cmd), file);
     5d6:	f8040513          	addi	a0,s0,-128
     5da:	00000097          	auipc	ra,0x0
     5de:	738080e7          	jalr	1848(ra) # d12 <strlen>
     5e2:	1502                	slli	a0,a0,0x20
     5e4:	9101                	srli	a0,a0,0x20
     5e6:	fd040593          	addi	a1,s0,-48
     5ea:	f8040793          	addi	a5,s0,-128
     5ee:	953e                	add	a0,a0,a5
     5f0:	00000097          	auipc	ra,0x0
     5f4:	6d2080e7          	jalr	1746(ra) # cc2 <strcpy>
  strcpy(cmd+strlen(cmd), "\n");
     5f8:	f8040513          	addi	a0,s0,-128
     5fc:	00000097          	auipc	ra,0x0
     600:	716080e7          	jalr	1814(ra) # d12 <strlen>
     604:	1502                	slli	a0,a0,0x20
     606:	9101                	srli	a0,a0,0x20
     608:	00001597          	auipc	a1,0x1
     60c:	f8858593          	addi	a1,a1,-120 # 1590 <malloc+0x1fe>
     610:	f8040793          	addi	a5,s0,-128
     614:	953e                	add	a0,a0,a5
     616:	00000097          	auipc	ra,0x0
     61a:	6ac080e7          	jalr	1708(ra) # cc2 <strcpy>

  if(one(cmd, "", 1) == 0){
     61e:	4605                	li	a2,1
     620:	00001597          	auipc	a1,0x1
     624:	f1058593          	addi	a1,a1,-240 # 1530 <malloc+0x19e>
     628:	f8040513          	addi	a0,s0,-128
     62c:	00000097          	auipc	ra,0x0
     630:	c04080e7          	jalr	-1020(ra) # 230 <one>
     634:	e515                	bnez	a0,660 <t4+0x11e>
    printf("FAIL\n");
     636:	00001517          	auipc	a0,0x1
     63a:	fd250513          	addi	a0,a0,-46 # 1608 <malloc+0x276>
     63e:	00001097          	auipc	ra,0x1
     642:	c94080e7          	jalr	-876(ra) # 12d2 <printf>
    *ok = 0;
     646:	0004a023          	sw	zero,0(s1)
    } else {
      printf("PASS\n");
    }
  }

  unlink(file);
     64a:	fd040513          	addi	a0,s0,-48
     64e:	00001097          	auipc	ra,0x1
     652:	954080e7          	jalr	-1708(ra) # fa2 <unlink>
}
     656:	70ea                	ld	ra,184(sp)
     658:	744a                	ld	s0,176(sp)
     65a:	74aa                	ld	s1,168(sp)
     65c:	6129                	addi	sp,sp,192
     65e:	8082                	ret
    readfile(file, buf, sizeof(buf));
     660:	04000613          	li	a2,64
     664:	f4040593          	addi	a1,s0,-192
     668:	fd040513          	addi	a0,s0,-48
     66c:	00000097          	auipc	ra,0x0
     670:	aee080e7          	jalr	-1298(ra) # 15a <readfile>
    if(strstr(buf, data) == 0){
     674:	fc040593          	addi	a1,s0,-64
     678:	f4040513          	addi	a0,s0,-192
     67c:	00000097          	auipc	ra,0x0
     680:	b68080e7          	jalr	-1176(ra) # 1e4 <strstr>
     684:	c911                	beqz	a0,698 <t4+0x156>
      printf("PASS\n");
     686:	00001517          	auipc	a0,0x1
     68a:	f8a50513          	addi	a0,a0,-118 # 1610 <malloc+0x27e>
     68e:	00001097          	auipc	ra,0x1
     692:	c44080e7          	jalr	-956(ra) # 12d2 <printf>
     696:	bf55                	j	64a <t4+0x108>
      printf("FAIL\n");
     698:	00001517          	auipc	a0,0x1
     69c:	f7050513          	addi	a0,a0,-144 # 1608 <malloc+0x276>
     6a0:	00001097          	auipc	ra,0x1
     6a4:	c32080e7          	jalr	-974(ra) # 12d2 <printf>
      *ok = 0;
     6a8:	0004a023          	sw	zero,0(s1)
     6ac:	bf79                	j	64a <t4+0x108>

00000000000006ae <t5>:

// test input redirection: cat < file
void
t5(int *ok)
{
     6ae:	7119                	addi	sp,sp,-128
     6b0:	fc86                	sd	ra,120(sp)
     6b2:	f8a2                	sd	s0,112(sp)
     6b4:	f4a6                	sd	s1,104(sp)
     6b6:	0100                	addi	s0,sp,128
     6b8:	84aa                	mv	s1,a0
  printf("input redirection: ");
     6ba:	00001517          	auipc	a0,0x1
     6be:	00e50513          	addi	a0,a0,14 # 16c8 <malloc+0x336>
     6c2:	00001097          	auipc	ra,0x1
     6c6:	c10080e7          	jalr	-1008(ra) # 12d2 <printf>

  char file[32];
  randstring(file, 12);
     6ca:	45b1                	li	a1,12
     6cc:	fc040513          	addi	a0,s0,-64
     6d0:	00000097          	auipc	ra,0x0
     6d4:	968080e7          	jalr	-1688(ra) # 38 <randstring>

  char data[32];
  randstring(data, 12);
     6d8:	45b1                	li	a1,12
     6da:	fa040513          	addi	a0,s0,-96
     6de:	00000097          	auipc	ra,0x0
     6e2:	95a080e7          	jalr	-1702(ra) # 38 <randstring>
  writefile(file, data);
     6e6:	fa040593          	addi	a1,s0,-96
     6ea:	fc040513          	addi	a0,s0,-64
     6ee:	00000097          	auipc	ra,0x0
     6f2:	9be080e7          	jalr	-1602(ra) # ac <writefile>

  char cmd[32];
  strcpy(cmd, "cat < ");
     6f6:	00001597          	auipc	a1,0x1
     6fa:	fea58593          	addi	a1,a1,-22 # 16e0 <malloc+0x34e>
     6fe:	f8040513          	addi	a0,s0,-128
     702:	00000097          	auipc	ra,0x0
     706:	5c0080e7          	jalr	1472(ra) # cc2 <strcpy>
  strcpy(cmd+strlen(cmd), file);
     70a:	f8040513          	addi	a0,s0,-128
     70e:	00000097          	auipc	ra,0x0
     712:	604080e7          	jalr	1540(ra) # d12 <strlen>
     716:	1502                	slli	a0,a0,0x20
     718:	9101                	srli	a0,a0,0x20
     71a:	fc040593          	addi	a1,s0,-64
     71e:	f8040793          	addi	a5,s0,-128
     722:	953e                	add	a0,a0,a5
     724:	00000097          	auipc	ra,0x0
     728:	59e080e7          	jalr	1438(ra) # cc2 <strcpy>
  strcpy(cmd+strlen(cmd), "\n");
     72c:	f8040513          	addi	a0,s0,-128
     730:	00000097          	auipc	ra,0x0
     734:	5e2080e7          	jalr	1506(ra) # d12 <strlen>
     738:	1502                	slli	a0,a0,0x20
     73a:	9101                	srli	a0,a0,0x20
     73c:	00001597          	auipc	a1,0x1
     740:	e5458593          	addi	a1,a1,-428 # 1590 <malloc+0x1fe>
     744:	f8040793          	addi	a5,s0,-128
     748:	953e                	add	a0,a0,a5
     74a:	00000097          	auipc	ra,0x0
     74e:	578080e7          	jalr	1400(ra) # cc2 <strcpy>

  if(one(cmd, data, 1) == 0){
     752:	4605                	li	a2,1
     754:	fa040593          	addi	a1,s0,-96
     758:	f8040513          	addi	a0,s0,-128
     75c:	00000097          	auipc	ra,0x0
     760:	ad4080e7          	jalr	-1324(ra) # 230 <one>
     764:	e515                	bnez	a0,790 <t5+0xe2>
    printf("FAIL\n");
     766:	00001517          	auipc	a0,0x1
     76a:	ea250513          	addi	a0,a0,-350 # 1608 <malloc+0x276>
     76e:	00001097          	auipc	ra,0x1
     772:	b64080e7          	jalr	-1180(ra) # 12d2 <printf>
    *ok = 0;
     776:	0004a023          	sw	zero,0(s1)
  } else {
    printf("PASS\n");
  }

  unlink(file);
     77a:	fc040513          	addi	a0,s0,-64
     77e:	00001097          	auipc	ra,0x1
     782:	824080e7          	jalr	-2012(ra) # fa2 <unlink>
}
     786:	70e6                	ld	ra,120(sp)
     788:	7446                	ld	s0,112(sp)
     78a:	74a6                	ld	s1,104(sp)
     78c:	6109                	addi	sp,sp,128
     78e:	8082                	ret
    printf("PASS\n");
     790:	00001517          	auipc	a0,0x1
     794:	e8050513          	addi	a0,a0,-384 # 1610 <malloc+0x27e>
     798:	00001097          	auipc	ra,0x1
     79c:	b3a080e7          	jalr	-1222(ra) # 12d2 <printf>
     7a0:	bfe9                	j	77a <t5+0xcc>

00000000000007a2 <t6>:

// test a command with both input and output redirection.
void
t6(int *ok)
{
     7a2:	711d                	addi	sp,sp,-96
     7a4:	ec86                	sd	ra,88(sp)
     7a6:	e8a2                	sd	s0,80(sp)
     7a8:	e4a6                	sd	s1,72(sp)
     7aa:	1080                	addi	s0,sp,96
     7ac:	84aa                	mv	s1,a0
  printf("both redirections: ");
     7ae:	00001517          	auipc	a0,0x1
     7b2:	f3a50513          	addi	a0,a0,-198 # 16e8 <malloc+0x356>
     7b6:	00001097          	auipc	ra,0x1
     7ba:	b1c080e7          	jalr	-1252(ra) # 12d2 <printf>
  unlink("testsh.out");
     7be:	00001517          	auipc	a0,0x1
     7c2:	f4250513          	addi	a0,a0,-190 # 1700 <malloc+0x36e>
     7c6:	00000097          	auipc	ra,0x0
     7ca:	7dc080e7          	jalr	2012(ra) # fa2 <unlink>
  if(one("grep pointers < README > testsh.out\n", "", 1) == 0){
     7ce:	4605                	li	a2,1
     7d0:	00001597          	auipc	a1,0x1
     7d4:	d6058593          	addi	a1,a1,-672 # 1530 <malloc+0x19e>
     7d8:	00001517          	auipc	a0,0x1
     7dc:	f3850513          	addi	a0,a0,-200 # 1710 <malloc+0x37e>
     7e0:	00000097          	auipc	ra,0x0
     7e4:	a50080e7          	jalr	-1456(ra) # 230 <one>
     7e8:	e905                	bnez	a0,818 <t6+0x76>
    printf("FAIL\n");
     7ea:	00001517          	auipc	a0,0x1
     7ee:	e1e50513          	addi	a0,a0,-482 # 1608 <malloc+0x276>
     7f2:	00001097          	auipc	ra,0x1
     7f6:	ae0080e7          	jalr	-1312(ra) # 12d2 <printf>
    *ok = 0;
     7fa:	0004a023          	sw	zero,0(s1)
      *ok = 0;
    } else {
      printf("PASS\n");
    }
  }
  unlink("testsh.out");
     7fe:	00001517          	auipc	a0,0x1
     802:	f0250513          	addi	a0,a0,-254 # 1700 <malloc+0x36e>
     806:	00000097          	auipc	ra,0x0
     80a:	79c080e7          	jalr	1948(ra) # fa2 <unlink>
}
     80e:	60e6                	ld	ra,88(sp)
     810:	6446                	ld	s0,80(sp)
     812:	64a6                	ld	s1,72(sp)
     814:	6125                	addi	sp,sp,96
     816:	8082                	ret
    readfile("testsh.out", buf, sizeof(buf));
     818:	04000613          	li	a2,64
     81c:	fa040593          	addi	a1,s0,-96
     820:	00001517          	auipc	a0,0x1
     824:	ee050513          	addi	a0,a0,-288 # 1700 <malloc+0x36e>
     828:	00000097          	auipc	ra,0x0
     82c:	932080e7          	jalr	-1742(ra) # 15a <readfile>
    if(strstr(buf, "provides pointers to on-line resources") == 0){
     830:	00001597          	auipc	a1,0x1
     834:	f0858593          	addi	a1,a1,-248 # 1738 <malloc+0x3a6>
     838:	fa040513          	addi	a0,s0,-96
     83c:	00000097          	auipc	ra,0x0
     840:	9a8080e7          	jalr	-1624(ra) # 1e4 <strstr>
     844:	c911                	beqz	a0,858 <t6+0xb6>
      printf("PASS\n");
     846:	00001517          	auipc	a0,0x1
     84a:	dca50513          	addi	a0,a0,-566 # 1610 <malloc+0x27e>
     84e:	00001097          	auipc	ra,0x1
     852:	a84080e7          	jalr	-1404(ra) # 12d2 <printf>
     856:	b765                	j	7fe <t6+0x5c>
      printf("FAIL\n");
     858:	00001517          	auipc	a0,0x1
     85c:	db050513          	addi	a0,a0,-592 # 1608 <malloc+0x276>
     860:	00001097          	auipc	ra,0x1
     864:	a72080e7          	jalr	-1422(ra) # 12d2 <printf>
      *ok = 0;
     868:	0004a023          	sw	zero,0(s1)
     86c:	bf49                	j	7fe <t6+0x5c>

000000000000086e <t7>:

// test a pipe with cat filename | cat.
void
t7(int *ok)
{
     86e:	7135                	addi	sp,sp,-160
     870:	ed06                	sd	ra,152(sp)
     872:	e922                	sd	s0,144(sp)
     874:	e526                	sd	s1,136(sp)
     876:	1100                	addi	s0,sp,160
     878:	84aa                	mv	s1,a0
  printf("simple pipe: ");
     87a:	00001517          	auipc	a0,0x1
     87e:	ee650513          	addi	a0,a0,-282 # 1760 <malloc+0x3ce>
     882:	00001097          	auipc	ra,0x1
     886:	a50080e7          	jalr	-1456(ra) # 12d2 <printf>

  char name[32], data[32];
  randstring(name, 12);
     88a:	45b1                	li	a1,12
     88c:	fc040513          	addi	a0,s0,-64
     890:	fffff097          	auipc	ra,0xfffff
     894:	7a8080e7          	jalr	1960(ra) # 38 <randstring>
  randstring(data, 12);
     898:	45b1                	li	a1,12
     89a:	fa040513          	addi	a0,s0,-96
     89e:	fffff097          	auipc	ra,0xfffff
     8a2:	79a080e7          	jalr	1946(ra) # 38 <randstring>
  writefile(name, data);
     8a6:	fa040593          	addi	a1,s0,-96
     8aa:	fc040513          	addi	a0,s0,-64
     8ae:	fffff097          	auipc	ra,0xfffff
     8b2:	7fe080e7          	jalr	2046(ra) # ac <writefile>

  char cmd[64];
  strcpy(cmd, "cat ");
     8b6:	00001597          	auipc	a1,0x1
     8ba:	eba58593          	addi	a1,a1,-326 # 1770 <malloc+0x3de>
     8be:	f6040513          	addi	a0,s0,-160
     8c2:	00000097          	auipc	ra,0x0
     8c6:	400080e7          	jalr	1024(ra) # cc2 <strcpy>
  strcpy(cmd + strlen(cmd), name);
     8ca:	f6040513          	addi	a0,s0,-160
     8ce:	00000097          	auipc	ra,0x0
     8d2:	444080e7          	jalr	1092(ra) # d12 <strlen>
     8d6:	1502                	slli	a0,a0,0x20
     8d8:	9101                	srli	a0,a0,0x20
     8da:	fc040593          	addi	a1,s0,-64
     8de:	f6040793          	addi	a5,s0,-160
     8e2:	953e                	add	a0,a0,a5
     8e4:	00000097          	auipc	ra,0x0
     8e8:	3de080e7          	jalr	990(ra) # cc2 <strcpy>
  strcpy(cmd + strlen(cmd), " | cat\n");
     8ec:	f6040513          	addi	a0,s0,-160
     8f0:	00000097          	auipc	ra,0x0
     8f4:	422080e7          	jalr	1058(ra) # d12 <strlen>
     8f8:	1502                	slli	a0,a0,0x20
     8fa:	9101                	srli	a0,a0,0x20
     8fc:	00001597          	auipc	a1,0x1
     900:	e7c58593          	addi	a1,a1,-388 # 1778 <malloc+0x3e6>
     904:	f6040793          	addi	a5,s0,-160
     908:	953e                	add	a0,a0,a5
     90a:	00000097          	auipc	ra,0x0
     90e:	3b8080e7          	jalr	952(ra) # cc2 <strcpy>
  
  if(one(cmd, data, 1) == 0){
     912:	4605                	li	a2,1
     914:	fa040593          	addi	a1,s0,-96
     918:	f6040513          	addi	a0,s0,-160
     91c:	00000097          	auipc	ra,0x0
     920:	914080e7          	jalr	-1772(ra) # 230 <one>
     924:	e515                	bnez	a0,950 <t7+0xe2>
    printf("FAIL\n");
     926:	00001517          	auipc	a0,0x1
     92a:	ce250513          	addi	a0,a0,-798 # 1608 <malloc+0x276>
     92e:	00001097          	auipc	ra,0x1
     932:	9a4080e7          	jalr	-1628(ra) # 12d2 <printf>
    *ok = 0;
     936:	0004a023          	sw	zero,0(s1)
  } else {
    printf("PASS\n");
  }

  unlink(name);
     93a:	fc040513          	addi	a0,s0,-64
     93e:	00000097          	auipc	ra,0x0
     942:	664080e7          	jalr	1636(ra) # fa2 <unlink>
}
     946:	60ea                	ld	ra,152(sp)
     948:	644a                	ld	s0,144(sp)
     94a:	64aa                	ld	s1,136(sp)
     94c:	610d                	addi	sp,sp,160
     94e:	8082                	ret
    printf("PASS\n");
     950:	00001517          	auipc	a0,0x1
     954:	cc050513          	addi	a0,a0,-832 # 1610 <malloc+0x27e>
     958:	00001097          	auipc	ra,0x1
     95c:	97a080e7          	jalr	-1670(ra) # 12d2 <printf>
     960:	bfe9                	j	93a <t7+0xcc>

0000000000000962 <t8>:

// test a pipeline that has both redirection and a pipe.
void
t8(int *ok)
{
     962:	711d                	addi	sp,sp,-96
     964:	ec86                	sd	ra,88(sp)
     966:	e8a2                	sd	s0,80(sp)
     968:	e4a6                	sd	s1,72(sp)
     96a:	1080                	addi	s0,sp,96
     96c:	84aa                	mv	s1,a0
  printf("pipe and redirects: ");
     96e:	00001517          	auipc	a0,0x1
     972:	e1250513          	addi	a0,a0,-494 # 1780 <malloc+0x3ee>
     976:	00001097          	auipc	ra,0x1
     97a:	95c080e7          	jalr	-1700(ra) # 12d2 <printf>
  
  if(one("grep suggestions < README | wc > testsh.out\n", "", 1) == 0){
     97e:	4605                	li	a2,1
     980:	00001597          	auipc	a1,0x1
     984:	bb058593          	addi	a1,a1,-1104 # 1530 <malloc+0x19e>
     988:	00001517          	auipc	a0,0x1
     98c:	e1050513          	addi	a0,a0,-496 # 1798 <malloc+0x406>
     990:	00000097          	auipc	ra,0x0
     994:	8a0080e7          	jalr	-1888(ra) # 230 <one>
     998:	e905                	bnez	a0,9c8 <t8+0x66>
    printf("FAIL\n");
     99a:	00001517          	auipc	a0,0x1
     99e:	c6e50513          	addi	a0,a0,-914 # 1608 <malloc+0x276>
     9a2:	00001097          	auipc	ra,0x1
     9a6:	930080e7          	jalr	-1744(ra) # 12d2 <printf>
    *ok = 0;
     9aa:	0004a023          	sw	zero,0(s1)
    } else {
      printf("PASS\n");
    }
  }

  unlink("testsh.out");
     9ae:	00001517          	auipc	a0,0x1
     9b2:	d5250513          	addi	a0,a0,-686 # 1700 <malloc+0x36e>
     9b6:	00000097          	auipc	ra,0x0
     9ba:	5ec080e7          	jalr	1516(ra) # fa2 <unlink>
}
     9be:	60e6                	ld	ra,88(sp)
     9c0:	6446                	ld	s0,80(sp)
     9c2:	64a6                	ld	s1,72(sp)
     9c4:	6125                	addi	sp,sp,96
     9c6:	8082                	ret
    readfile("testsh.out", buf, sizeof(buf));
     9c8:	04000613          	li	a2,64
     9cc:	fa040593          	addi	a1,s0,-96
     9d0:	00001517          	auipc	a0,0x1
     9d4:	d3050513          	addi	a0,a0,-720 # 1700 <malloc+0x36e>
     9d8:	fffff097          	auipc	ra,0xfffff
     9dc:	782080e7          	jalr	1922(ra) # 15a <readfile>
    if(strstr(buf, "1 11 71") == 0){
     9e0:	00001597          	auipc	a1,0x1
     9e4:	de858593          	addi	a1,a1,-536 # 17c8 <malloc+0x436>
     9e8:	fa040513          	addi	a0,s0,-96
     9ec:	fffff097          	auipc	ra,0xfffff
     9f0:	7f8080e7          	jalr	2040(ra) # 1e4 <strstr>
     9f4:	c911                	beqz	a0,a08 <t8+0xa6>
      printf("PASS\n");
     9f6:	00001517          	auipc	a0,0x1
     9fa:	c1a50513          	addi	a0,a0,-998 # 1610 <malloc+0x27e>
     9fe:	00001097          	auipc	ra,0x1
     a02:	8d4080e7          	jalr	-1836(ra) # 12d2 <printf>
     a06:	b765                	j	9ae <t8+0x4c>
      printf("FAIL\n");
     a08:	00001517          	auipc	a0,0x1
     a0c:	c0050513          	addi	a0,a0,-1024 # 1608 <malloc+0x276>
     a10:	00001097          	auipc	ra,0x1
     a14:	8c2080e7          	jalr	-1854(ra) # 12d2 <printf>
      *ok = 0;
     a18:	0004a023          	sw	zero,0(s1)
     a1c:	bf49                	j	9ae <t8+0x4c>

0000000000000a1e <t9>:

// ask the shell to execute many commands, to check
// if it leaks file descriptors.
void
t9(int *ok)
{
     a1e:	7159                	addi	sp,sp,-112
     a20:	f486                	sd	ra,104(sp)
     a22:	f0a2                	sd	s0,96(sp)
     a24:	eca6                	sd	s1,88(sp)
     a26:	e8ca                	sd	s2,80(sp)
     a28:	e4ce                	sd	s3,72(sp)
     a2a:	e0d2                	sd	s4,64(sp)
     a2c:	fc56                	sd	s5,56(sp)
     a2e:	f85a                	sd	s6,48(sp)
     a30:	f45e                	sd	s7,40(sp)
     a32:	1880                	addi	s0,sp,112
     a34:	8baa                	mv	s7,a0
  printf("lots of commands: ");
     a36:	00001517          	auipc	a0,0x1
     a3a:	d9a50513          	addi	a0,a0,-614 # 17d0 <malloc+0x43e>
     a3e:	00001097          	auipc	ra,0x1
     a42:	894080e7          	jalr	-1900(ra) # 12d2 <printf>

  char term[32];
  randstring(term, 12);
     a46:	45b1                	li	a1,12
     a48:	f9040513          	addi	a0,s0,-112
     a4c:	fffff097          	auipc	ra,0xfffff
     a50:	5ec080e7          	jalr	1516(ra) # 38 <randstring>
  
  char *cmd = malloc(25 * 36 + 100);
     a54:	3e800513          	li	a0,1000
     a58:	00001097          	auipc	ra,0x1
     a5c:	93a080e7          	jalr	-1734(ra) # 1392 <malloc>
  if(cmd == 0){
     a60:	14050363          	beqz	a0,ba6 <t9+0x188>
     a64:	84aa                	mv	s1,a0
    fprintf(2, "testsh: malloc failed\n");
    exit(-1);
  }

  cmd[0] = '\0';
     a66:	00050023          	sb	zero,0(a0)
  for(int i = 0; i < 17+(rand()%6); i++){
     a6a:	fffff097          	auipc	ra,0xfffff
     a6e:	596080e7          	jalr	1430(ra) # 0 <rand>
     a72:	4981                	li	s3,0
    strcpy(cmd + strlen(cmd), "echo x < README > tso\n");
     a74:	00001b17          	auipc	s6,0x1
     a78:	d8cb0b13          	addi	s6,s6,-628 # 1800 <malloc+0x46e>
    strcpy(cmd + strlen(cmd), "echo x | echo\n");
     a7c:	00001a97          	auipc	s5,0x1
     a80:	d9ca8a93          	addi	s5,s5,-612 # 1818 <malloc+0x486>
  for(int i = 0; i < 17+(rand()%6); i++){
     a84:	4a19                	li	s4,6
    strcpy(cmd + strlen(cmd), "echo x < README > tso\n");
     a86:	8526                	mv	a0,s1
     a88:	00000097          	auipc	ra,0x0
     a8c:	28a080e7          	jalr	650(ra) # d12 <strlen>
     a90:	1502                	slli	a0,a0,0x20
     a92:	9101                	srli	a0,a0,0x20
     a94:	85da                	mv	a1,s6
     a96:	9526                	add	a0,a0,s1
     a98:	00000097          	auipc	ra,0x0
     a9c:	22a080e7          	jalr	554(ra) # cc2 <strcpy>
    strcpy(cmd + strlen(cmd), "echo x | echo\n");
     aa0:	8526                	mv	a0,s1
     aa2:	00000097          	auipc	ra,0x0
     aa6:	270080e7          	jalr	624(ra) # d12 <strlen>
     aaa:	1502                	slli	a0,a0,0x20
     aac:	9101                	srli	a0,a0,0x20
     aae:	85d6                	mv	a1,s5
     ab0:	9526                	add	a0,a0,s1
     ab2:	00000097          	auipc	ra,0x0
     ab6:	210080e7          	jalr	528(ra) # cc2 <strcpy>
  for(int i = 0; i < 17+(rand()%6); i++){
     aba:	0019891b          	addiw	s2,s3,1
     abe:	0009099b          	sext.w	s3,s2
     ac2:	fffff097          	auipc	ra,0xfffff
     ac6:	53e080e7          	jalr	1342(ra) # 0 <rand>
     aca:	0345753b          	remuw	a0,a0,s4
     ace:	2545                	addiw	a0,a0,17
     ad0:	faa9ebe3          	bltu	s3,a0,a86 <t9+0x68>
  }
  strcpy(cmd + strlen(cmd), "echo ");
     ad4:	8526                	mv	a0,s1
     ad6:	00000097          	auipc	ra,0x0
     ada:	23c080e7          	jalr	572(ra) # d12 <strlen>
     ade:	1502                	slli	a0,a0,0x20
     ae0:	9101                	srli	a0,a0,0x20
     ae2:	00001597          	auipc	a1,0x1
     ae6:	bd658593          	addi	a1,a1,-1066 # 16b8 <malloc+0x326>
     aea:	9526                	add	a0,a0,s1
     aec:	00000097          	auipc	ra,0x0
     af0:	1d6080e7          	jalr	470(ra) # cc2 <strcpy>
  strcpy(cmd + strlen(cmd), term);
     af4:	8526                	mv	a0,s1
     af6:	00000097          	auipc	ra,0x0
     afa:	21c080e7          	jalr	540(ra) # d12 <strlen>
     afe:	1502                	slli	a0,a0,0x20
     b00:	9101                	srli	a0,a0,0x20
     b02:	f9040593          	addi	a1,s0,-112
     b06:	9526                	add	a0,a0,s1
     b08:	00000097          	auipc	ra,0x0
     b0c:	1ba080e7          	jalr	442(ra) # cc2 <strcpy>
  strcpy(cmd + strlen(cmd), " > tso\n");
     b10:	8526                	mv	a0,s1
     b12:	00000097          	auipc	ra,0x0
     b16:	200080e7          	jalr	512(ra) # d12 <strlen>
     b1a:	1502                	slli	a0,a0,0x20
     b1c:	9101                	srli	a0,a0,0x20
     b1e:	00001597          	auipc	a1,0x1
     b22:	d0a58593          	addi	a1,a1,-758 # 1828 <malloc+0x496>
     b26:	9526                	add	a0,a0,s1
     b28:	00000097          	auipc	ra,0x0
     b2c:	19a080e7          	jalr	410(ra) # cc2 <strcpy>
  strcpy(cmd + strlen(cmd), "cat < tso\n");
     b30:	8526                	mv	a0,s1
     b32:	00000097          	auipc	ra,0x0
     b36:	1e0080e7          	jalr	480(ra) # d12 <strlen>
     b3a:	1502                	slli	a0,a0,0x20
     b3c:	9101                	srli	a0,a0,0x20
     b3e:	00001597          	auipc	a1,0x1
     b42:	cf258593          	addi	a1,a1,-782 # 1830 <malloc+0x49e>
     b46:	9526                	add	a0,a0,s1
     b48:	00000097          	auipc	ra,0x0
     b4c:	17a080e7          	jalr	378(ra) # cc2 <strcpy>

  if(one(cmd, term, 0) == 0){
     b50:	4601                	li	a2,0
     b52:	f9040593          	addi	a1,s0,-112
     b56:	8526                	mv	a0,s1
     b58:	fffff097          	auipc	ra,0xfffff
     b5c:	6d8080e7          	jalr	1752(ra) # 230 <one>
     b60:	e12d                	bnez	a0,bc2 <t9+0x1a4>
    printf("FAIL\n");
     b62:	00001517          	auipc	a0,0x1
     b66:	aa650513          	addi	a0,a0,-1370 # 1608 <malloc+0x276>
     b6a:	00000097          	auipc	ra,0x0
     b6e:	768080e7          	jalr	1896(ra) # 12d2 <printf>
    *ok = 0;
     b72:	000ba023          	sw	zero,0(s7)
  } else {
    printf("PASS\n");
  }

  unlink("tso");
     b76:	00001517          	auipc	a0,0x1
     b7a:	cca50513          	addi	a0,a0,-822 # 1840 <malloc+0x4ae>
     b7e:	00000097          	auipc	ra,0x0
     b82:	424080e7          	jalr	1060(ra) # fa2 <unlink>
  free(cmd);
     b86:	8526                	mv	a0,s1
     b88:	00000097          	auipc	ra,0x0
     b8c:	780080e7          	jalr	1920(ra) # 1308 <free>
}
     b90:	70a6                	ld	ra,104(sp)
     b92:	7406                	ld	s0,96(sp)
     b94:	64e6                	ld	s1,88(sp)
     b96:	6946                	ld	s2,80(sp)
     b98:	69a6                	ld	s3,72(sp)
     b9a:	6a06                	ld	s4,64(sp)
     b9c:	7ae2                	ld	s5,56(sp)
     b9e:	7b42                	ld	s6,48(sp)
     ba0:	7ba2                	ld	s7,40(sp)
     ba2:	6165                	addi	sp,sp,112
     ba4:	8082                	ret
    fprintf(2, "testsh: malloc failed\n");
     ba6:	00001597          	auipc	a1,0x1
     baa:	c4258593          	addi	a1,a1,-958 # 17e8 <malloc+0x456>
     bae:	4509                	li	a0,2
     bb0:	00000097          	auipc	ra,0x0
     bb4:	6f4080e7          	jalr	1780(ra) # 12a4 <fprintf>
    exit(-1);
     bb8:	557d                	li	a0,-1
     bba:	00000097          	auipc	ra,0x0
     bbe:	398080e7          	jalr	920(ra) # f52 <exit>
    printf("PASS\n");
     bc2:	00001517          	auipc	a0,0x1
     bc6:	a4e50513          	addi	a0,a0,-1458 # 1610 <malloc+0x27e>
     bca:	00000097          	auipc	ra,0x0
     bce:	708080e7          	jalr	1800(ra) # 12d2 <printf>
     bd2:	b755                	j	b76 <t9+0x158>

0000000000000bd4 <main>:

int
main(int argc, char *argv[])
{
     bd4:	1101                	addi	sp,sp,-32
     bd6:	ec06                	sd	ra,24(sp)
     bd8:	e822                	sd	s0,16(sp)
     bda:	1000                	addi	s0,sp,32
  if(argc != 2){
     bdc:	4789                	li	a5,2
     bde:	02f50063          	beq	a0,a5,bfe <main+0x2a>
    fprintf(2, "Usage: testsh nsh\n");
     be2:	00001597          	auipc	a1,0x1
     be6:	c6658593          	addi	a1,a1,-922 # 1848 <malloc+0x4b6>
     bea:	4509                	li	a0,2
     bec:	00000097          	auipc	ra,0x0
     bf0:	6b8080e7          	jalr	1720(ra) # 12a4 <fprintf>
    exit(-1);
     bf4:	557d                	li	a0,-1
     bf6:	00000097          	auipc	ra,0x0
     bfa:	35c080e7          	jalr	860(ra) # f52 <exit>
  }
  shname = argv[1];
     bfe:	659c                	ld	a5,8(a1)
     c00:	00001717          	auipc	a4,0x1
     c04:	caf73c23          	sd	a5,-840(a4) # 18b8 <shname>
  
  seed += getpid();
     c08:	00000097          	auipc	ra,0x0
     c0c:	3ca080e7          	jalr	970(ra) # fd2 <getpid>
     c10:	00001717          	auipc	a4,0x1
     c14:	ca070713          	addi	a4,a4,-864 # 18b0 <seed>
     c18:	431c                	lw	a5,0(a4)
     c1a:	9d3d                	addw	a0,a0,a5
     c1c:	c308                	sw	a0,0(a4)

  int ok = 1;
     c1e:	4785                	li	a5,1
     c20:	fef42623          	sw	a5,-20(s0)

  t1(&ok);
     c24:	fec40513          	addi	a0,s0,-20
     c28:	fffff097          	auipc	ra,0xfffff
     c2c:	7e2080e7          	jalr	2018(ra) # 40a <t1>
  t2(&ok);
     c30:	fec40513          	addi	a0,s0,-20
     c34:	00000097          	auipc	ra,0x0
     c38:	83e080e7          	jalr	-1986(ra) # 472 <t2>
  t3(&ok);
     c3c:	fec40513          	addi	a0,s0,-20
     c40:	00000097          	auipc	ra,0x0
     c44:	89a080e7          	jalr	-1894(ra) # 4da <t3>
  t4(&ok);
     c48:	fec40513          	addi	a0,s0,-20
     c4c:	00000097          	auipc	ra,0x0
     c50:	8f6080e7          	jalr	-1802(ra) # 542 <t4>
  t5(&ok);
     c54:	fec40513          	addi	a0,s0,-20
     c58:	00000097          	auipc	ra,0x0
     c5c:	a56080e7          	jalr	-1450(ra) # 6ae <t5>
  t6(&ok);
     c60:	fec40513          	addi	a0,s0,-20
     c64:	00000097          	auipc	ra,0x0
     c68:	b3e080e7          	jalr	-1218(ra) # 7a2 <t6>
  t7(&ok);
     c6c:	fec40513          	addi	a0,s0,-20
     c70:	00000097          	auipc	ra,0x0
     c74:	bfe080e7          	jalr	-1026(ra) # 86e <t7>
  t8(&ok);
     c78:	fec40513          	addi	a0,s0,-20
     c7c:	00000097          	auipc	ra,0x0
     c80:	ce6080e7          	jalr	-794(ra) # 962 <t8>
  t9(&ok);
     c84:	fec40513          	addi	a0,s0,-20
     c88:	00000097          	auipc	ra,0x0
     c8c:	d96080e7          	jalr	-618(ra) # a1e <t9>

  if(ok){
     c90:	fec42783          	lw	a5,-20(s0)
     c94:	cf91                	beqz	a5,cb0 <main+0xdc>
    printf("passed all tests\n");
     c96:	00001517          	auipc	a0,0x1
     c9a:	bca50513          	addi	a0,a0,-1078 # 1860 <malloc+0x4ce>
     c9e:	00000097          	auipc	ra,0x0
     ca2:	634080e7          	jalr	1588(ra) # 12d2 <printf>
  } else {
    printf("failed some tests\n");
  }
  
  exit(0);
     ca6:	4501                	li	a0,0
     ca8:	00000097          	auipc	ra,0x0
     cac:	2aa080e7          	jalr	682(ra) # f52 <exit>
    printf("failed some tests\n");
     cb0:	00001517          	auipc	a0,0x1
     cb4:	bc850513          	addi	a0,a0,-1080 # 1878 <malloc+0x4e6>
     cb8:	00000097          	auipc	ra,0x0
     cbc:	61a080e7          	jalr	1562(ra) # 12d2 <printf>
     cc0:	b7dd                	j	ca6 <main+0xd2>

0000000000000cc2 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"

char*
strcpy(char *s, const char *t)
{
     cc2:	1141                	addi	sp,sp,-16
     cc4:	e422                	sd	s0,8(sp)
     cc6:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
     cc8:	87aa                	mv	a5,a0
     cca:	0585                	addi	a1,a1,1
     ccc:	0785                	addi	a5,a5,1
     cce:	fff5c703          	lbu	a4,-1(a1)
     cd2:	fee78fa3          	sb	a4,-1(a5)
     cd6:	fb75                	bnez	a4,cca <strcpy+0x8>
    ;
  return os;
}
     cd8:	6422                	ld	s0,8(sp)
     cda:	0141                	addi	sp,sp,16
     cdc:	8082                	ret

0000000000000cde <strcmp>:

int
strcmp(const char *p, const char *q)
{
     cde:	1141                	addi	sp,sp,-16
     ce0:	e422                	sd	s0,8(sp)
     ce2:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
     ce4:	00054783          	lbu	a5,0(a0)
     ce8:	cf91                	beqz	a5,d04 <strcmp+0x26>
     cea:	0005c703          	lbu	a4,0(a1)
     cee:	00f71b63          	bne	a4,a5,d04 <strcmp+0x26>
    p++, q++;
     cf2:	0505                	addi	a0,a0,1
     cf4:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
     cf6:	00054783          	lbu	a5,0(a0)
     cfa:	c789                	beqz	a5,d04 <strcmp+0x26>
     cfc:	0005c703          	lbu	a4,0(a1)
     d00:	fef709e3          	beq	a4,a5,cf2 <strcmp+0x14>
  return (uchar)*p - (uchar)*q;
     d04:	0005c503          	lbu	a0,0(a1)
}
     d08:	40a7853b          	subw	a0,a5,a0
     d0c:	6422                	ld	s0,8(sp)
     d0e:	0141                	addi	sp,sp,16
     d10:	8082                	ret

0000000000000d12 <strlen>:

uint
strlen(const char *s)
{
     d12:	1141                	addi	sp,sp,-16
     d14:	e422                	sd	s0,8(sp)
     d16:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
     d18:	00054783          	lbu	a5,0(a0)
     d1c:	cf91                	beqz	a5,d38 <strlen+0x26>
     d1e:	0505                	addi	a0,a0,1
     d20:	87aa                	mv	a5,a0
     d22:	4685                	li	a3,1
     d24:	9e89                	subw	a3,a3,a0
     d26:	00f6853b          	addw	a0,a3,a5
     d2a:	0785                	addi	a5,a5,1
     d2c:	fff7c703          	lbu	a4,-1(a5)
     d30:	fb7d                	bnez	a4,d26 <strlen+0x14>
    ;
  return n;
}
     d32:	6422                	ld	s0,8(sp)
     d34:	0141                	addi	sp,sp,16
     d36:	8082                	ret
  for(n = 0; s[n]; n++)
     d38:	4501                	li	a0,0
     d3a:	bfe5                	j	d32 <strlen+0x20>

0000000000000d3c <memset>:

void*
memset(void *dst, int c, uint n)
{
     d3c:	1141                	addi	sp,sp,-16
     d3e:	e422                	sd	s0,8(sp)
     d40:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
     d42:	ce09                	beqz	a2,d5c <memset+0x20>
     d44:	87aa                	mv	a5,a0
     d46:	fff6071b          	addiw	a4,a2,-1
     d4a:	1702                	slli	a4,a4,0x20
     d4c:	9301                	srli	a4,a4,0x20
     d4e:	0705                	addi	a4,a4,1
     d50:	972a                	add	a4,a4,a0
    cdst[i] = c;
     d52:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
     d56:	0785                	addi	a5,a5,1
     d58:	fee79de3          	bne	a5,a4,d52 <memset+0x16>
  }
  return dst;
}
     d5c:	6422                	ld	s0,8(sp)
     d5e:	0141                	addi	sp,sp,16
     d60:	8082                	ret

0000000000000d62 <strchr>:

char*
strchr(const char *s, char c)
{
     d62:	1141                	addi	sp,sp,-16
     d64:	e422                	sd	s0,8(sp)
     d66:	0800                	addi	s0,sp,16
  for(; *s; s++)
     d68:	00054783          	lbu	a5,0(a0)
     d6c:	cf91                	beqz	a5,d88 <strchr+0x26>
    if(*s == c)
     d6e:	00f58a63          	beq	a1,a5,d82 <strchr+0x20>
  for(; *s; s++)
     d72:	0505                	addi	a0,a0,1
     d74:	00054783          	lbu	a5,0(a0)
     d78:	c781                	beqz	a5,d80 <strchr+0x1e>
    if(*s == c)
     d7a:	feb79ce3          	bne	a5,a1,d72 <strchr+0x10>
     d7e:	a011                	j	d82 <strchr+0x20>
      return (char*)s;
  return 0;
     d80:	4501                	li	a0,0
}
     d82:	6422                	ld	s0,8(sp)
     d84:	0141                	addi	sp,sp,16
     d86:	8082                	ret
  return 0;
     d88:	4501                	li	a0,0
     d8a:	bfe5                	j	d82 <strchr+0x20>

0000000000000d8c <gets>:

char*
gets(char *buf, int max)
{
     d8c:	711d                	addi	sp,sp,-96
     d8e:	ec86                	sd	ra,88(sp)
     d90:	e8a2                	sd	s0,80(sp)
     d92:	e4a6                	sd	s1,72(sp)
     d94:	e0ca                	sd	s2,64(sp)
     d96:	fc4e                	sd	s3,56(sp)
     d98:	f852                	sd	s4,48(sp)
     d9a:	f456                	sd	s5,40(sp)
     d9c:	f05a                	sd	s6,32(sp)
     d9e:	ec5e                	sd	s7,24(sp)
     da0:	1080                	addi	s0,sp,96
     da2:	8baa                	mv	s7,a0
     da4:	8a2e                	mv	s4,a1
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
     da6:	892a                	mv	s2,a0
     da8:	4981                	li	s3,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
     daa:	4aa9                	li	s5,10
     dac:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
     dae:	0019849b          	addiw	s1,s3,1
     db2:	0344d863          	ble	s4,s1,de2 <gets+0x56>
    cc = read(0, &c, 1);
     db6:	4605                	li	a2,1
     db8:	faf40593          	addi	a1,s0,-81
     dbc:	4501                	li	a0,0
     dbe:	00000097          	auipc	ra,0x0
     dc2:	1ac080e7          	jalr	428(ra) # f6a <read>
    if(cc < 1)
     dc6:	00a05e63          	blez	a0,de2 <gets+0x56>
    buf[i++] = c;
     dca:	faf44783          	lbu	a5,-81(s0)
     dce:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
     dd2:	01578763          	beq	a5,s5,de0 <gets+0x54>
     dd6:	0905                	addi	s2,s2,1
  for(i=0; i+1 < max; ){
     dd8:	89a6                	mv	s3,s1
    if(c == '\n' || c == '\r')
     dda:	fd679ae3          	bne	a5,s6,dae <gets+0x22>
     dde:	a011                	j	de2 <gets+0x56>
  for(i=0; i+1 < max; ){
     de0:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
     de2:	99de                	add	s3,s3,s7
     de4:	00098023          	sb	zero,0(s3)
  return buf;
}
     de8:	855e                	mv	a0,s7
     dea:	60e6                	ld	ra,88(sp)
     dec:	6446                	ld	s0,80(sp)
     dee:	64a6                	ld	s1,72(sp)
     df0:	6906                	ld	s2,64(sp)
     df2:	79e2                	ld	s3,56(sp)
     df4:	7a42                	ld	s4,48(sp)
     df6:	7aa2                	ld	s5,40(sp)
     df8:	7b02                	ld	s6,32(sp)
     dfa:	6be2                	ld	s7,24(sp)
     dfc:	6125                	addi	sp,sp,96
     dfe:	8082                	ret

0000000000000e00 <stat>:

int
stat(const char *n, struct stat *st)
{
     e00:	1101                	addi	sp,sp,-32
     e02:	ec06                	sd	ra,24(sp)
     e04:	e822                	sd	s0,16(sp)
     e06:	e426                	sd	s1,8(sp)
     e08:	e04a                	sd	s2,0(sp)
     e0a:	1000                	addi	s0,sp,32
     e0c:	892e                	mv	s2,a1
  int fd;
  int r;

  fd = open(n, O_RDONLY);
     e0e:	4581                	li	a1,0
     e10:	00000097          	auipc	ra,0x0
     e14:	182080e7          	jalr	386(ra) # f92 <open>
  if(fd < 0)
     e18:	02054563          	bltz	a0,e42 <stat+0x42>
     e1c:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
     e1e:	85ca                	mv	a1,s2
     e20:	00000097          	auipc	ra,0x0
     e24:	18a080e7          	jalr	394(ra) # faa <fstat>
     e28:	892a                	mv	s2,a0
  close(fd);
     e2a:	8526                	mv	a0,s1
     e2c:	00000097          	auipc	ra,0x0
     e30:	14e080e7          	jalr	334(ra) # f7a <close>
  return r;
}
     e34:	854a                	mv	a0,s2
     e36:	60e2                	ld	ra,24(sp)
     e38:	6442                	ld	s0,16(sp)
     e3a:	64a2                	ld	s1,8(sp)
     e3c:	6902                	ld	s2,0(sp)
     e3e:	6105                	addi	sp,sp,32
     e40:	8082                	ret
    return -1;
     e42:	597d                	li	s2,-1
     e44:	bfc5                	j	e34 <stat+0x34>

0000000000000e46 <atoi>:

int
atoi(const char *s)
{
     e46:	1141                	addi	sp,sp,-16
     e48:	e422                	sd	s0,8(sp)
     e4a:	0800                	addi	s0,sp,16
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
     e4c:	00054683          	lbu	a3,0(a0)
     e50:	fd06879b          	addiw	a5,a3,-48
     e54:	0ff7f793          	andi	a5,a5,255
     e58:	4725                	li	a4,9
     e5a:	02f76963          	bltu	a4,a5,e8c <atoi+0x46>
     e5e:	862a                	mv	a2,a0
  n = 0;
     e60:	4501                	li	a0,0
  while('0' <= *s && *s <= '9')
     e62:	45a5                	li	a1,9
    n = n*10 + *s++ - '0';
     e64:	0605                	addi	a2,a2,1
     e66:	0025179b          	slliw	a5,a0,0x2
     e6a:	9fa9                	addw	a5,a5,a0
     e6c:	0017979b          	slliw	a5,a5,0x1
     e70:	9fb5                	addw	a5,a5,a3
     e72:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
     e76:	00064683          	lbu	a3,0(a2)
     e7a:	fd06871b          	addiw	a4,a3,-48
     e7e:	0ff77713          	andi	a4,a4,255
     e82:	fee5f1e3          	bleu	a4,a1,e64 <atoi+0x1e>
  return n;
}
     e86:	6422                	ld	s0,8(sp)
     e88:	0141                	addi	sp,sp,16
     e8a:	8082                	ret
  n = 0;
     e8c:	4501                	li	a0,0
     e8e:	bfe5                	j	e86 <atoi+0x40>

0000000000000e90 <memmove>:

void*
memmove(void *vdst, const void *vsrc, int n)
{
     e90:	1141                	addi	sp,sp,-16
     e92:	e422                	sd	s0,8(sp)
     e94:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;

  dst = vdst;
  src = vsrc;
  if (src > dst) {
     e96:	02b57663          	bleu	a1,a0,ec2 <memmove+0x32>
    while(n-- > 0)
     e9a:	02c05163          	blez	a2,ebc <memmove+0x2c>
     e9e:	fff6079b          	addiw	a5,a2,-1
     ea2:	1782                	slli	a5,a5,0x20
     ea4:	9381                	srli	a5,a5,0x20
     ea6:	0785                	addi	a5,a5,1
     ea8:	97aa                	add	a5,a5,a0
  dst = vdst;
     eaa:	872a                	mv	a4,a0
      *dst++ = *src++;
     eac:	0585                	addi	a1,a1,1
     eae:	0705                	addi	a4,a4,1
     eb0:	fff5c683          	lbu	a3,-1(a1)
     eb4:	fed70fa3          	sb	a3,-1(a4)
    while(n-- > 0)
     eb8:	fee79ae3          	bne	a5,a4,eac <memmove+0x1c>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
     ebc:	6422                	ld	s0,8(sp)
     ebe:	0141                	addi	sp,sp,16
     ec0:	8082                	ret
    dst += n;
     ec2:	00c50733          	add	a4,a0,a2
    src += n;
     ec6:	95b2                	add	a1,a1,a2
    while(n-- > 0)
     ec8:	fec05ae3          	blez	a2,ebc <memmove+0x2c>
     ecc:	fff6079b          	addiw	a5,a2,-1
     ed0:	1782                	slli	a5,a5,0x20
     ed2:	9381                	srli	a5,a5,0x20
     ed4:	fff7c793          	not	a5,a5
     ed8:	97ba                	add	a5,a5,a4
      *--dst = *--src;
     eda:	15fd                	addi	a1,a1,-1
     edc:	177d                	addi	a4,a4,-1
     ede:	0005c683          	lbu	a3,0(a1)
     ee2:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
     ee6:	fef71ae3          	bne	a4,a5,eda <memmove+0x4a>
     eea:	bfc9                	j	ebc <memmove+0x2c>

0000000000000eec <memcmp>:

int
memcmp(const void *s1, const void *s2, uint n)
{
     eec:	1141                	addi	sp,sp,-16
     eee:	e422                	sd	s0,8(sp)
     ef0:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
     ef2:	ce15                	beqz	a2,f2e <memcmp+0x42>
     ef4:	fff6069b          	addiw	a3,a2,-1
    if (*p1 != *p2) {
     ef8:	00054783          	lbu	a5,0(a0)
     efc:	0005c703          	lbu	a4,0(a1)
     f00:	02e79063          	bne	a5,a4,f20 <memcmp+0x34>
     f04:	1682                	slli	a3,a3,0x20
     f06:	9281                	srli	a3,a3,0x20
     f08:	0685                	addi	a3,a3,1
     f0a:	96aa                	add	a3,a3,a0
      return *p1 - *p2;
    }
    p1++;
     f0c:	0505                	addi	a0,a0,1
    p2++;
     f0e:	0585                	addi	a1,a1,1
  while (n-- > 0) {
     f10:	00d50d63          	beq	a0,a3,f2a <memcmp+0x3e>
    if (*p1 != *p2) {
     f14:	00054783          	lbu	a5,0(a0)
     f18:	0005c703          	lbu	a4,0(a1)
     f1c:	fee788e3          	beq	a5,a4,f0c <memcmp+0x20>
      return *p1 - *p2;
     f20:	40e7853b          	subw	a0,a5,a4
  }
  return 0;
}
     f24:	6422                	ld	s0,8(sp)
     f26:	0141                	addi	sp,sp,16
     f28:	8082                	ret
  return 0;
     f2a:	4501                	li	a0,0
     f2c:	bfe5                	j	f24 <memcmp+0x38>
     f2e:	4501                	li	a0,0
     f30:	bfd5                	j	f24 <memcmp+0x38>

0000000000000f32 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
     f32:	1141                	addi	sp,sp,-16
     f34:	e406                	sd	ra,8(sp)
     f36:	e022                	sd	s0,0(sp)
     f38:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
     f3a:	00000097          	auipc	ra,0x0
     f3e:	f56080e7          	jalr	-170(ra) # e90 <memmove>
}
     f42:	60a2                	ld	ra,8(sp)
     f44:	6402                	ld	s0,0(sp)
     f46:	0141                	addi	sp,sp,16
     f48:	8082                	ret

0000000000000f4a <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
     f4a:	4885                	li	a7,1
 ecall
     f4c:	00000073          	ecall
 ret
     f50:	8082                	ret

0000000000000f52 <exit>:
.global exit
exit:
 li a7, SYS_exit
     f52:	4889                	li	a7,2
 ecall
     f54:	00000073          	ecall
 ret
     f58:	8082                	ret

0000000000000f5a <wait>:
.global wait
wait:
 li a7, SYS_wait
     f5a:	488d                	li	a7,3
 ecall
     f5c:	00000073          	ecall
 ret
     f60:	8082                	ret

0000000000000f62 <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
     f62:	4891                	li	a7,4
 ecall
     f64:	00000073          	ecall
 ret
     f68:	8082                	ret

0000000000000f6a <read>:
.global read
read:
 li a7, SYS_read
     f6a:	4895                	li	a7,5
 ecall
     f6c:	00000073          	ecall
 ret
     f70:	8082                	ret

0000000000000f72 <write>:
.global write
write:
 li a7, SYS_write
     f72:	48c1                	li	a7,16
 ecall
     f74:	00000073          	ecall
 ret
     f78:	8082                	ret

0000000000000f7a <close>:
.global close
close:
 li a7, SYS_close
     f7a:	48d5                	li	a7,21
 ecall
     f7c:	00000073          	ecall
 ret
     f80:	8082                	ret

0000000000000f82 <kill>:
.global kill
kill:
 li a7, SYS_kill
     f82:	4899                	li	a7,6
 ecall
     f84:	00000073          	ecall
 ret
     f88:	8082                	ret

0000000000000f8a <exec>:
.global exec
exec:
 li a7, SYS_exec
     f8a:	489d                	li	a7,7
 ecall
     f8c:	00000073          	ecall
 ret
     f90:	8082                	ret

0000000000000f92 <open>:
.global open
open:
 li a7, SYS_open
     f92:	48bd                	li	a7,15
 ecall
     f94:	00000073          	ecall
 ret
     f98:	8082                	ret

0000000000000f9a <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
     f9a:	48c5                	li	a7,17
 ecall
     f9c:	00000073          	ecall
 ret
     fa0:	8082                	ret

0000000000000fa2 <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
     fa2:	48c9                	li	a7,18
 ecall
     fa4:	00000073          	ecall
 ret
     fa8:	8082                	ret

0000000000000faa <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
     faa:	48a1                	li	a7,8
 ecall
     fac:	00000073          	ecall
 ret
     fb0:	8082                	ret

0000000000000fb2 <link>:
.global link
link:
 li a7, SYS_link
     fb2:	48cd                	li	a7,19
 ecall
     fb4:	00000073          	ecall
 ret
     fb8:	8082                	ret

0000000000000fba <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
     fba:	48d1                	li	a7,20
 ecall
     fbc:	00000073          	ecall
 ret
     fc0:	8082                	ret

0000000000000fc2 <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
     fc2:	48a5                	li	a7,9
 ecall
     fc4:	00000073          	ecall
 ret
     fc8:	8082                	ret

0000000000000fca <dup>:
.global dup
dup:
 li a7, SYS_dup
     fca:	48a9                	li	a7,10
 ecall
     fcc:	00000073          	ecall
 ret
     fd0:	8082                	ret

0000000000000fd2 <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
     fd2:	48ad                	li	a7,11
 ecall
     fd4:	00000073          	ecall
 ret
     fd8:	8082                	ret

0000000000000fda <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
     fda:	48b1                	li	a7,12
 ecall
     fdc:	00000073          	ecall
 ret
     fe0:	8082                	ret

0000000000000fe2 <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
     fe2:	48b5                	li	a7,13
 ecall
     fe4:	00000073          	ecall
 ret
     fe8:	8082                	ret

0000000000000fea <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
     fea:	48b9                	li	a7,14
 ecall
     fec:	00000073          	ecall
 ret
     ff0:	8082                	ret

0000000000000ff2 <ntas>:
.global ntas
ntas:
 li a7, SYS_ntas
     ff2:	48d9                	li	a7,22
 ecall
     ff4:	00000073          	ecall
 ret
     ff8:	8082                	ret

0000000000000ffa <putc>:

static char digits[] = "0123456789ABCDEF";

static void
putc(int fd, char c)
{
     ffa:	1101                	addi	sp,sp,-32
     ffc:	ec06                	sd	ra,24(sp)
     ffe:	e822                	sd	s0,16(sp)
    1000:	1000                	addi	s0,sp,32
    1002:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
    1006:	4605                	li	a2,1
    1008:	fef40593          	addi	a1,s0,-17
    100c:	00000097          	auipc	ra,0x0
    1010:	f66080e7          	jalr	-154(ra) # f72 <write>
}
    1014:	60e2                	ld	ra,24(sp)
    1016:	6442                	ld	s0,16(sp)
    1018:	6105                	addi	sp,sp,32
    101a:	8082                	ret

000000000000101c <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
    101c:	7139                	addi	sp,sp,-64
    101e:	fc06                	sd	ra,56(sp)
    1020:	f822                	sd	s0,48(sp)
    1022:	f426                	sd	s1,40(sp)
    1024:	f04a                	sd	s2,32(sp)
    1026:	ec4e                	sd	s3,24(sp)
    1028:	0080                	addi	s0,sp,64
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
    102a:	c299                	beqz	a3,1030 <printint+0x14>
    102c:	0005cd63          	bltz	a1,1046 <printint+0x2a>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
    1030:	2581                	sext.w	a1,a1
  neg = 0;
    1032:	4301                	li	t1,0
    1034:	fc040713          	addi	a4,s0,-64
  }

  i = 0;
    1038:	4801                	li	a6,0
  do{
    buf[i++] = digits[x % base];
    103a:	2601                	sext.w	a2,a2
    103c:	00001897          	auipc	a7,0x1
    1040:	85488893          	addi	a7,a7,-1964 # 1890 <digits>
    1044:	a801                	j	1054 <printint+0x38>
    x = -xx;
    1046:	40b005bb          	negw	a1,a1
    104a:	2581                	sext.w	a1,a1
    neg = 1;
    104c:	4305                	li	t1,1
    x = -xx;
    104e:	b7dd                	j	1034 <printint+0x18>
  }while((x /= base) != 0);
    1050:	85be                	mv	a1,a5
    buf[i++] = digits[x % base];
    1052:	8836                	mv	a6,a3
    1054:	0018069b          	addiw	a3,a6,1
    1058:	02c5f7bb          	remuw	a5,a1,a2
    105c:	1782                	slli	a5,a5,0x20
    105e:	9381                	srli	a5,a5,0x20
    1060:	97c6                	add	a5,a5,a7
    1062:	0007c783          	lbu	a5,0(a5)
    1066:	00f70023          	sb	a5,0(a4)
  }while((x /= base) != 0);
    106a:	0705                	addi	a4,a4,1
    106c:	02c5d7bb          	divuw	a5,a1,a2
    1070:	fec5f0e3          	bleu	a2,a1,1050 <printint+0x34>
  if(neg)
    1074:	00030b63          	beqz	t1,108a <printint+0x6e>
    buf[i++] = '-';
    1078:	fd040793          	addi	a5,s0,-48
    107c:	96be                	add	a3,a3,a5
    107e:	02d00793          	li	a5,45
    1082:	fef68823          	sb	a5,-16(a3)
    1086:	0028069b          	addiw	a3,a6,2

  while(--i >= 0)
    108a:	02d05963          	blez	a3,10bc <printint+0xa0>
    108e:	89aa                	mv	s3,a0
    1090:	fc040793          	addi	a5,s0,-64
    1094:	00d784b3          	add	s1,a5,a3
    1098:	fff78913          	addi	s2,a5,-1
    109c:	9936                	add	s2,s2,a3
    109e:	36fd                	addiw	a3,a3,-1
    10a0:	1682                	slli	a3,a3,0x20
    10a2:	9281                	srli	a3,a3,0x20
    10a4:	40d90933          	sub	s2,s2,a3
    putc(fd, buf[i]);
    10a8:	fff4c583          	lbu	a1,-1(s1)
    10ac:	854e                	mv	a0,s3
    10ae:	00000097          	auipc	ra,0x0
    10b2:	f4c080e7          	jalr	-180(ra) # ffa <putc>
  while(--i >= 0)
    10b6:	14fd                	addi	s1,s1,-1
    10b8:	ff2498e3          	bne	s1,s2,10a8 <printint+0x8c>
}
    10bc:	70e2                	ld	ra,56(sp)
    10be:	7442                	ld	s0,48(sp)
    10c0:	74a2                	ld	s1,40(sp)
    10c2:	7902                	ld	s2,32(sp)
    10c4:	69e2                	ld	s3,24(sp)
    10c6:	6121                	addi	sp,sp,64
    10c8:	8082                	ret

00000000000010ca <vprintf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
    10ca:	7119                	addi	sp,sp,-128
    10cc:	fc86                	sd	ra,120(sp)
    10ce:	f8a2                	sd	s0,112(sp)
    10d0:	f4a6                	sd	s1,104(sp)
    10d2:	f0ca                	sd	s2,96(sp)
    10d4:	ecce                	sd	s3,88(sp)
    10d6:	e8d2                	sd	s4,80(sp)
    10d8:	e4d6                	sd	s5,72(sp)
    10da:	e0da                	sd	s6,64(sp)
    10dc:	fc5e                	sd	s7,56(sp)
    10de:	f862                	sd	s8,48(sp)
    10e0:	f466                	sd	s9,40(sp)
    10e2:	f06a                	sd	s10,32(sp)
    10e4:	ec6e                	sd	s11,24(sp)
    10e6:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;

  state = 0;
  for(i = 0; fmt[i]; i++){
    10e8:	0005c483          	lbu	s1,0(a1)
    10ec:	18048d63          	beqz	s1,1286 <vprintf+0x1bc>
    10f0:	8aaa                	mv	s5,a0
    10f2:	8b32                	mv	s6,a2
    10f4:	00158913          	addi	s2,a1,1
  state = 0;
    10f8:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
    10fa:	02500a13          	li	s4,37
      if(c == 'd'){
    10fe:	06400c13          	li	s8,100
        printint(fd, va_arg(ap, int), 10, 1);
      } else if(c == 'l') {
    1102:	06c00c93          	li	s9,108
        printint(fd, va_arg(ap, uint64), 10, 0);
      } else if(c == 'x') {
    1106:	07800d13          	li	s10,120
        printint(fd, va_arg(ap, int), 16, 0);
      } else if(c == 'p') {
    110a:	07000d93          	li	s11,112
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
    110e:	00000b97          	auipc	s7,0x0
    1112:	782b8b93          	addi	s7,s7,1922 # 1890 <digits>
    1116:	a839                	j	1134 <vprintf+0x6a>
        putc(fd, c);
    1118:	85a6                	mv	a1,s1
    111a:	8556                	mv	a0,s5
    111c:	00000097          	auipc	ra,0x0
    1120:	ede080e7          	jalr	-290(ra) # ffa <putc>
    1124:	a019                	j	112a <vprintf+0x60>
    } else if(state == '%'){
    1126:	01498f63          	beq	s3,s4,1144 <vprintf+0x7a>
  for(i = 0; fmt[i]; i++){
    112a:	0905                	addi	s2,s2,1
    112c:	fff94483          	lbu	s1,-1(s2)
    1130:	14048b63          	beqz	s1,1286 <vprintf+0x1bc>
    c = fmt[i] & 0xff;
    1134:	0004879b          	sext.w	a5,s1
    if(state == 0){
    1138:	fe0997e3          	bnez	s3,1126 <vprintf+0x5c>
      if(c == '%'){
    113c:	fd479ee3          	bne	a5,s4,1118 <vprintf+0x4e>
        state = '%';
    1140:	89be                	mv	s3,a5
    1142:	b7e5                	j	112a <vprintf+0x60>
      if(c == 'd'){
    1144:	05878063          	beq	a5,s8,1184 <vprintf+0xba>
      } else if(c == 'l') {
    1148:	05978c63          	beq	a5,s9,11a0 <vprintf+0xd6>
      } else if(c == 'x') {
    114c:	07a78863          	beq	a5,s10,11bc <vprintf+0xf2>
      } else if(c == 'p') {
    1150:	09b78463          	beq	a5,s11,11d8 <vprintf+0x10e>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
    1154:	07300713          	li	a4,115
    1158:	0ce78563          	beq	a5,a4,1222 <vprintf+0x158>
          s = "(null)";
        while(*s != 0){
          putc(fd, *s);
          s++;
        }
      } else if(c == 'c'){
    115c:	06300713          	li	a4,99
    1160:	0ee78c63          	beq	a5,a4,1258 <vprintf+0x18e>
        putc(fd, va_arg(ap, uint));
      } else if(c == '%'){
    1164:	11478663          	beq	a5,s4,1270 <vprintf+0x1a6>
        putc(fd, c);
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
    1168:	85d2                	mv	a1,s4
    116a:	8556                	mv	a0,s5
    116c:	00000097          	auipc	ra,0x0
    1170:	e8e080e7          	jalr	-370(ra) # ffa <putc>
        putc(fd, c);
    1174:	85a6                	mv	a1,s1
    1176:	8556                	mv	a0,s5
    1178:	00000097          	auipc	ra,0x0
    117c:	e82080e7          	jalr	-382(ra) # ffa <putc>
      }
      state = 0;
    1180:	4981                	li	s3,0
    1182:	b765                	j	112a <vprintf+0x60>
        printint(fd, va_arg(ap, int), 10, 1);
    1184:	008b0493          	addi	s1,s6,8
    1188:	4685                	li	a3,1
    118a:	4629                	li	a2,10
    118c:	000b2583          	lw	a1,0(s6)
    1190:	8556                	mv	a0,s5
    1192:	00000097          	auipc	ra,0x0
    1196:	e8a080e7          	jalr	-374(ra) # 101c <printint>
    119a:	8b26                	mv	s6,s1
      state = 0;
    119c:	4981                	li	s3,0
    119e:	b771                	j	112a <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
    11a0:	008b0493          	addi	s1,s6,8
    11a4:	4681                	li	a3,0
    11a6:	4629                	li	a2,10
    11a8:	000b2583          	lw	a1,0(s6)
    11ac:	8556                	mv	a0,s5
    11ae:	00000097          	auipc	ra,0x0
    11b2:	e6e080e7          	jalr	-402(ra) # 101c <printint>
    11b6:	8b26                	mv	s6,s1
      state = 0;
    11b8:	4981                	li	s3,0
    11ba:	bf85                	j	112a <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
    11bc:	008b0493          	addi	s1,s6,8
    11c0:	4681                	li	a3,0
    11c2:	4641                	li	a2,16
    11c4:	000b2583          	lw	a1,0(s6)
    11c8:	8556                	mv	a0,s5
    11ca:	00000097          	auipc	ra,0x0
    11ce:	e52080e7          	jalr	-430(ra) # 101c <printint>
    11d2:	8b26                	mv	s6,s1
      state = 0;
    11d4:	4981                	li	s3,0
    11d6:	bf91                	j	112a <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
    11d8:	008b0793          	addi	a5,s6,8
    11dc:	f8f43423          	sd	a5,-120(s0)
    11e0:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
    11e4:	03000593          	li	a1,48
    11e8:	8556                	mv	a0,s5
    11ea:	00000097          	auipc	ra,0x0
    11ee:	e10080e7          	jalr	-496(ra) # ffa <putc>
  putc(fd, 'x');
    11f2:	85ea                	mv	a1,s10
    11f4:	8556                	mv	a0,s5
    11f6:	00000097          	auipc	ra,0x0
    11fa:	e04080e7          	jalr	-508(ra) # ffa <putc>
    11fe:	44c1                	li	s1,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
    1200:	03c9d793          	srli	a5,s3,0x3c
    1204:	97de                	add	a5,a5,s7
    1206:	0007c583          	lbu	a1,0(a5)
    120a:	8556                	mv	a0,s5
    120c:	00000097          	auipc	ra,0x0
    1210:	dee080e7          	jalr	-530(ra) # ffa <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
    1214:	0992                	slli	s3,s3,0x4
    1216:	34fd                	addiw	s1,s1,-1
    1218:	f4e5                	bnez	s1,1200 <vprintf+0x136>
        printptr(fd, va_arg(ap, uint64));
    121a:	f8843b03          	ld	s6,-120(s0)
      state = 0;
    121e:	4981                	li	s3,0
    1220:	b729                	j	112a <vprintf+0x60>
        s = va_arg(ap, char*);
    1222:	008b0993          	addi	s3,s6,8
    1226:	000b3483          	ld	s1,0(s6)
        if(s == 0)
    122a:	c085                	beqz	s1,124a <vprintf+0x180>
        while(*s != 0){
    122c:	0004c583          	lbu	a1,0(s1)
    1230:	c9a1                	beqz	a1,1280 <vprintf+0x1b6>
          putc(fd, *s);
    1232:	8556                	mv	a0,s5
    1234:	00000097          	auipc	ra,0x0
    1238:	dc6080e7          	jalr	-570(ra) # ffa <putc>
          s++;
    123c:	0485                	addi	s1,s1,1
        while(*s != 0){
    123e:	0004c583          	lbu	a1,0(s1)
    1242:	f9e5                	bnez	a1,1232 <vprintf+0x168>
        s = va_arg(ap, char*);
    1244:	8b4e                	mv	s6,s3
      state = 0;
    1246:	4981                	li	s3,0
    1248:	b5cd                	j	112a <vprintf+0x60>
          s = "(null)";
    124a:	00000497          	auipc	s1,0x0
    124e:	65e48493          	addi	s1,s1,1630 # 18a8 <digits+0x18>
        while(*s != 0){
    1252:	02800593          	li	a1,40
    1256:	bff1                	j	1232 <vprintf+0x168>
        putc(fd, va_arg(ap, uint));
    1258:	008b0493          	addi	s1,s6,8
    125c:	000b4583          	lbu	a1,0(s6)
    1260:	8556                	mv	a0,s5
    1262:	00000097          	auipc	ra,0x0
    1266:	d98080e7          	jalr	-616(ra) # ffa <putc>
    126a:	8b26                	mv	s6,s1
      state = 0;
    126c:	4981                	li	s3,0
    126e:	bd75                	j	112a <vprintf+0x60>
        putc(fd, c);
    1270:	85d2                	mv	a1,s4
    1272:	8556                	mv	a0,s5
    1274:	00000097          	auipc	ra,0x0
    1278:	d86080e7          	jalr	-634(ra) # ffa <putc>
      state = 0;
    127c:	4981                	li	s3,0
    127e:	b575                	j	112a <vprintf+0x60>
        s = va_arg(ap, char*);
    1280:	8b4e                	mv	s6,s3
      state = 0;
    1282:	4981                	li	s3,0
    1284:	b55d                	j	112a <vprintf+0x60>
    }
  }
}
    1286:	70e6                	ld	ra,120(sp)
    1288:	7446                	ld	s0,112(sp)
    128a:	74a6                	ld	s1,104(sp)
    128c:	7906                	ld	s2,96(sp)
    128e:	69e6                	ld	s3,88(sp)
    1290:	6a46                	ld	s4,80(sp)
    1292:	6aa6                	ld	s5,72(sp)
    1294:	6b06                	ld	s6,64(sp)
    1296:	7be2                	ld	s7,56(sp)
    1298:	7c42                	ld	s8,48(sp)
    129a:	7ca2                	ld	s9,40(sp)
    129c:	7d02                	ld	s10,32(sp)
    129e:	6de2                	ld	s11,24(sp)
    12a0:	6109                	addi	sp,sp,128
    12a2:	8082                	ret

00000000000012a4 <fprintf>:

void
fprintf(int fd, const char *fmt, ...)
{
    12a4:	715d                	addi	sp,sp,-80
    12a6:	ec06                	sd	ra,24(sp)
    12a8:	e822                	sd	s0,16(sp)
    12aa:	1000                	addi	s0,sp,32
    12ac:	e010                	sd	a2,0(s0)
    12ae:	e414                	sd	a3,8(s0)
    12b0:	e818                	sd	a4,16(s0)
    12b2:	ec1c                	sd	a5,24(s0)
    12b4:	03043023          	sd	a6,32(s0)
    12b8:	03143423          	sd	a7,40(s0)
  va_list ap;

  va_start(ap, fmt);
    12bc:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
    12c0:	8622                	mv	a2,s0
    12c2:	00000097          	auipc	ra,0x0
    12c6:	e08080e7          	jalr	-504(ra) # 10ca <vprintf>
}
    12ca:	60e2                	ld	ra,24(sp)
    12cc:	6442                	ld	s0,16(sp)
    12ce:	6161                	addi	sp,sp,80
    12d0:	8082                	ret

00000000000012d2 <printf>:

void
printf(const char *fmt, ...)
{
    12d2:	711d                	addi	sp,sp,-96
    12d4:	ec06                	sd	ra,24(sp)
    12d6:	e822                	sd	s0,16(sp)
    12d8:	1000                	addi	s0,sp,32
    12da:	e40c                	sd	a1,8(s0)
    12dc:	e810                	sd	a2,16(s0)
    12de:	ec14                	sd	a3,24(s0)
    12e0:	f018                	sd	a4,32(s0)
    12e2:	f41c                	sd	a5,40(s0)
    12e4:	03043823          	sd	a6,48(s0)
    12e8:	03143c23          	sd	a7,56(s0)
  va_list ap;

  va_start(ap, fmt);
    12ec:	00840613          	addi	a2,s0,8
    12f0:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
    12f4:	85aa                	mv	a1,a0
    12f6:	4505                	li	a0,1
    12f8:	00000097          	auipc	ra,0x0
    12fc:	dd2080e7          	jalr	-558(ra) # 10ca <vprintf>
}
    1300:	60e2                	ld	ra,24(sp)
    1302:	6442                	ld	s0,16(sp)
    1304:	6125                	addi	sp,sp,96
    1306:	8082                	ret

0000000000001308 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
    1308:	1141                	addi	sp,sp,-16
    130a:	e422                	sd	s0,8(sp)
    130c:	0800                	addi	s0,sp,16
  Header *bp, *p;

  bp = (Header*)ap - 1;
    130e:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    1312:	00000797          	auipc	a5,0x0
    1316:	5ae78793          	addi	a5,a5,1454 # 18c0 <freep>
    131a:	639c                	ld	a5,0(a5)
    131c:	a805                	j	134c <free+0x44>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
    131e:	4618                	lw	a4,8(a2)
    1320:	9db9                	addw	a1,a1,a4
    1322:	feb52c23          	sw	a1,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
    1326:	6398                	ld	a4,0(a5)
    1328:	6318                	ld	a4,0(a4)
    132a:	fee53823          	sd	a4,-16(a0)
    132e:	a091                	j	1372 <free+0x6a>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
    1330:	ff852703          	lw	a4,-8(a0)
    1334:	9e39                	addw	a2,a2,a4
    1336:	c790                	sw	a2,8(a5)
    p->s.ptr = bp->s.ptr;
    1338:	ff053703          	ld	a4,-16(a0)
    133c:	e398                	sd	a4,0(a5)
    133e:	a099                	j	1384 <free+0x7c>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
    1340:	6398                	ld	a4,0(a5)
    1342:	00e7e463          	bltu	a5,a4,134a <free+0x42>
    1346:	00e6ea63          	bltu	a3,a4,135a <free+0x52>
{
    134a:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    134c:	fed7fae3          	bleu	a3,a5,1340 <free+0x38>
    1350:	6398                	ld	a4,0(a5)
    1352:	00e6e463          	bltu	a3,a4,135a <free+0x52>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
    1356:	fee7eae3          	bltu	a5,a4,134a <free+0x42>
  if(bp + bp->s.size == p->s.ptr){
    135a:	ff852583          	lw	a1,-8(a0)
    135e:	6390                	ld	a2,0(a5)
    1360:	02059713          	slli	a4,a1,0x20
    1364:	9301                	srli	a4,a4,0x20
    1366:	0712                	slli	a4,a4,0x4
    1368:	9736                	add	a4,a4,a3
    136a:	fae60ae3          	beq	a2,a4,131e <free+0x16>
    bp->s.ptr = p->s.ptr;
    136e:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
    1372:	4790                	lw	a2,8(a5)
    1374:	02061713          	slli	a4,a2,0x20
    1378:	9301                	srli	a4,a4,0x20
    137a:	0712                	slli	a4,a4,0x4
    137c:	973e                	add	a4,a4,a5
    137e:	fae689e3          	beq	a3,a4,1330 <free+0x28>
  } else
    p->s.ptr = bp;
    1382:	e394                	sd	a3,0(a5)
  freep = p;
    1384:	00000717          	auipc	a4,0x0
    1388:	52f73e23          	sd	a5,1340(a4) # 18c0 <freep>
}
    138c:	6422                	ld	s0,8(sp)
    138e:	0141                	addi	sp,sp,16
    1390:	8082                	ret

0000000000001392 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
    1392:	7139                	addi	sp,sp,-64
    1394:	fc06                	sd	ra,56(sp)
    1396:	f822                	sd	s0,48(sp)
    1398:	f426                	sd	s1,40(sp)
    139a:	f04a                	sd	s2,32(sp)
    139c:	ec4e                	sd	s3,24(sp)
    139e:	e852                	sd	s4,16(sp)
    13a0:	e456                	sd	s5,8(sp)
    13a2:	e05a                	sd	s6,0(sp)
    13a4:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
    13a6:	02051993          	slli	s3,a0,0x20
    13aa:	0209d993          	srli	s3,s3,0x20
    13ae:	09bd                	addi	s3,s3,15
    13b0:	0049d993          	srli	s3,s3,0x4
    13b4:	2985                	addiw	s3,s3,1
    13b6:	0009891b          	sext.w	s2,s3
  if((prevp = freep) == 0){
    13ba:	00000797          	auipc	a5,0x0
    13be:	50678793          	addi	a5,a5,1286 # 18c0 <freep>
    13c2:	6388                	ld	a0,0(a5)
    13c4:	c515                	beqz	a0,13f0 <malloc+0x5e>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    13c6:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
    13c8:	4798                	lw	a4,8(a5)
    13ca:	03277f63          	bleu	s2,a4,1408 <malloc+0x76>
    13ce:	8a4e                	mv	s4,s3
    13d0:	0009871b          	sext.w	a4,s3
    13d4:	6685                	lui	a3,0x1
    13d6:	00d77363          	bleu	a3,a4,13dc <malloc+0x4a>
    13da:	6a05                	lui	s4,0x1
    13dc:	000a0a9b          	sext.w	s5,s4
  p = sbrk(nu * sizeof(Header));
    13e0:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
    13e4:	00000497          	auipc	s1,0x0
    13e8:	4dc48493          	addi	s1,s1,1244 # 18c0 <freep>
  if(p == (char*)-1)
    13ec:	5b7d                	li	s6,-1
    13ee:	a885                	j	145e <malloc+0xcc>
    base.s.ptr = freep = prevp = &base;
    13f0:	00000797          	auipc	a5,0x0
    13f4:	4d878793          	addi	a5,a5,1240 # 18c8 <base>
    13f8:	00000717          	auipc	a4,0x0
    13fc:	4cf73423          	sd	a5,1224(a4) # 18c0 <freep>
    1400:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
    1402:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
    1406:	b7e1                	j	13ce <malloc+0x3c>
      if(p->s.size == nunits)
    1408:	02e90b63          	beq	s2,a4,143e <malloc+0xac>
        p->s.size -= nunits;
    140c:	4137073b          	subw	a4,a4,s3
    1410:	c798                	sw	a4,8(a5)
        p += p->s.size;
    1412:	1702                	slli	a4,a4,0x20
    1414:	9301                	srli	a4,a4,0x20
    1416:	0712                	slli	a4,a4,0x4
    1418:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
    141a:	0137a423          	sw	s3,8(a5)
      freep = prevp;
    141e:	00000717          	auipc	a4,0x0
    1422:	4aa73123          	sd	a0,1186(a4) # 18c0 <freep>
      return (void*)(p + 1);
    1426:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
    142a:	70e2                	ld	ra,56(sp)
    142c:	7442                	ld	s0,48(sp)
    142e:	74a2                	ld	s1,40(sp)
    1430:	7902                	ld	s2,32(sp)
    1432:	69e2                	ld	s3,24(sp)
    1434:	6a42                	ld	s4,16(sp)
    1436:	6aa2                	ld	s5,8(sp)
    1438:	6b02                	ld	s6,0(sp)
    143a:	6121                	addi	sp,sp,64
    143c:	8082                	ret
        prevp->s.ptr = p->s.ptr;
    143e:	6398                	ld	a4,0(a5)
    1440:	e118                	sd	a4,0(a0)
    1442:	bff1                	j	141e <malloc+0x8c>
  hp->s.size = nu;
    1444:	01552423          	sw	s5,8(a0)
  free((void*)(hp + 1));
    1448:	0541                	addi	a0,a0,16
    144a:	00000097          	auipc	ra,0x0
    144e:	ebe080e7          	jalr	-322(ra) # 1308 <free>
  return freep;
    1452:	6088                	ld	a0,0(s1)
      if((p = morecore(nunits)) == 0)
    1454:	d979                	beqz	a0,142a <malloc+0x98>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    1456:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
    1458:	4798                	lw	a4,8(a5)
    145a:	fb2777e3          	bleu	s2,a4,1408 <malloc+0x76>
    if(p == freep)
    145e:	6098                	ld	a4,0(s1)
    1460:	853e                	mv	a0,a5
    1462:	fef71ae3          	bne	a4,a5,1456 <malloc+0xc4>
  p = sbrk(nu * sizeof(Header));
    1466:	8552                	mv	a0,s4
    1468:	00000097          	auipc	ra,0x0
    146c:	b72080e7          	jalr	-1166(ra) # fda <sbrk>
  if(p == (char*)-1)
    1470:	fd651ae3          	bne	a0,s6,1444 <malloc+0xb2>
        return 0;
    1474:	4501                	li	a0,0
    1476:	bf55                	j	142a <malloc+0x98>
